I'm using location.reload()
/ $window.location.reload()
function to reload my angular app, it reloads the page but also generates the following error in console:
[$rootScope:infdig] 10 $digest() iterations reached. Aborting!
I'm calling validateAuthToken from run method of app controller which internally calls location.reload() method.
.run(function ($rootScope, $urlRouter, security, $location) {
$rootScope.$on('$locationChangeSuccess', function(e) {
security.validateAuthToken();
});
});
angular.module('security', [])
.factory('security', [ '$http', '$q', '$location', function($http, $q, $location) {
var service = {
validateAuthToken: function() {
var request = $http.post(url, params);
return request.then(
function(response) {
if(CONDITION_MEETS) {
location.reload();
}
},
function(error) {
});
}
return service;
}]);
Complete error trace:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.8/$rootScope/infdig?p0=10&p1=%5B%5D
at REGEX_STRING_REGEXP (angular.js:63)
at Scope.promises.$get.Scope.$digest (angular.js:14263)
at Scope.promises.$get.Scope.$apply (angular.js:14488)
at done (angular.js:9646)
at completeRequest (angular.js:9836)
at XMLHttpRequest.requestError (angular.js:9787)