My problem is pretty simple, but I'm not able to find what out what happens.
All I want to do is read all posts from my local REST API. When I'm responding HTTP 401 from the API, AngularJS keeps repeating the GET requests in an infinite loop.
var request = {
method: 'GET',
url: 'http://jentzschserverdev-46690.onmodulus.net/index.php/issues',
headers: {
'Anonymous': true
}
};
$http(request)
.success(function(data){
console.log('success', data);
deferred.resolve(data.issues);
})
.error(function(){
console.log('error');
deferred.resolve([]);
});
The console tells me:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
at angular.js:63
at Scope.$digest (angular.js:14346)
at Scope.$apply (angular.js:14571)
at done (angular.js:9698)
at completeRequest (angular.js:9888)
at XMLHttpRequest.requestLoaded (angular.js:9829)(anonymous function)
@ angular.js:11655(anonymous function) @ angular.js:8596Scope.$apply
@ angular.js:14573done @ angular.js:9698completeRequest
@ angular.js:9888requestLoaded @ angular.js:9829 angular.js:63
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
For better understanding I created a plunker: http://embed.plnkr.co/R4tYUHei9vkylPgvAT5B/ (if you uncomment the code in app.js, your browser should crash due to the infinite loop)
Can anybody tell me what's happening here and why??