I want to call a function in angularJs everytime when I close the tab of browser. For this I have written this code:
$window.onbeforeunload = function() {
$scope.clientLogout('login');
};
$scope.clientLogout() is defined in the parent controller. Now when I close the tab from the parent controller, its working fine but its not able to call $scope.clientLogout() function when in child Controller.
I have also tried the below code and its working fine:
$window.onbeforeunload = function() {
return ('hi');
};
Can anyone explain me?