I have been trying to call a a logout service from whitin onunload or onbeforeunload window events.
This is because I needed to logout upon closure of window or a tab. I set $window.onbeforeunload within the run() block.
$window.onbeforeunload worked fine when I wanted to show a warning to the user upon closure of tab or window. But, when I tried to call a logout function from within the onbeforeunload event, the function was not called.
I tried calling the $http from within run() block or calling it from a data service, but the result was the same.
How can I solve this?