I have 2 controllers, both use the same update method to get data:
angular.module('project')
.controller('mainController', function($http, $scope, $timeout, $sce) {
updateData($http, $scope, $timeout, $sce, false);
})
.controller('settingsController', function($http, $scope, $timeout, $sce) {
updateData($http, $scope, $timeout, $sce, true);
})
my updateData looks like this:
function updateData($http, $scope, $timeout, $sce, settings) {
$timeout(function() {
if (settings) {
getSettings($http, $scope);
}
else {
getDataA($http, $scope);
getDataB($http, $scope);
}
updateData($http, $scope, $timeout, $sce, settings);
}, 1000);
}
Now when refreshing the main page (using mainController) I always get 'null' messages, because the process did not complete all method calls, and when switching to another site (using settingsController) it takes ages to load it because all requests from the previous one have to be completed first. How do I directly "kill" all pending updates when refreshing/switching site?