Angularjs: capture the refresh event in the browser
angularjs, javascript, jquery
Solution
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();
});
Problem
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