In angularjs is possible handle the user clicking the Refresh button on the browser? There is any method that the framework expose to the developer?
Thanks
In angularjs is possible handle the user clicking the Refresh button on the browser? There is any method that the framework expose to the developer?
Thanks
To handle the reload itself (which includes hitting F5) and to take action before it reloads or even cancel, use 'beforeunload' event.
var windowElement = angular.element($window);
windowElement.on('beforeunload', function (event) {
//Do Something
//After this will prevent reload or navigating away.
event.preventDefault();
});
You can use $routeChageStart
:
$rootScope.$on('$routeChangeStart', function () {
alert('refresh');
});