Can someone help me figure out how to call an AngularJS function when a window is closing? Currently, I have the following code:
app.controller("reportCtrl", function($scope, $http) {
$scope.deleteReport = function() {
$http.get("/SCTrakker/api/deleteReport").success(function() {
});
};
window.onbeforeunload = function(){
$scope.deleteReport();
}; });
The controller and angular libraries are loading successfully, so that's not the issue. However, the problem arises when attempting to close the window as the event doesn't execute and nothing happens. I'm at a loss for what else I can do.
Any suggestions would be greatly appreciated!