Angularjs: capture update events in browser

Is angularjs user friendly by clicking the refresh button in a browser? Is there any method that the infrastructure provides to the developer?

thanks

+6
source share
2 answers

To deal with the reboot itself (including the F5 hit) and take action before rebooting or even canceling, use the "beforeunload" event.

var windowElement = angular.element($window); windowElement.on('beforeunload', function (event) { //Do Something //After this will prevent reload or navigating away. event.preventDefault(); }); 
+4
source

You can use $routeChageStart :

  $rootScope.$on('$routeChangeStart', function () { alert('refresh'); }); 
0
source

Source: https://habr.com/ru/post/969962/


All Articles