$scope.saveStats = function () {
$http({
method: "post",
url: "save.php",
data: $scope.info
}).success(function () {
console.log($scope.info);
})
};
window.onbeforeunload = $scope.saveStats();
This code is not doing what I expect it to do. It just fires saveStats()
when loading the page. And when I exit the page, it does not fire saveStats()
.
I wrote this inside my angular controller. I'm pretty confused at the result...