jeudi 26 mars 2015

Angular - Error: 10 $digest() iterations reached. Aborting

i'm trying to put a random integer in my ng-src path, like that:



<img ng-src="{{randomPicture()}}" alt="">


And here's my basic function in my controller:



$scope.randomPicture = function(){
var PATH = 'assets/images/';
var image = Math.floor((Math.random() * 12) + 1);
var ext = '.jpg';
var randomPic = PATH + image + ext;

return randomPic;
};


The images are displayed but in the console i have this error:



Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!


I found many questions on that here in stackoverflow but i still can't get rid of that error. Thanks for your help.





Aucun commentaire:

Enregistrer un commentaire