Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using angularjs-google-maps and am getting an error when trying to loop over my customers as markers on a map.

<map>
  <custom-marker ng-repeat="cust in customers" position="[ {{ cust.lat }}, {{ cust.lon }} ]">
    <div class="{{ cust.category }}">{{ cust.name }}</div>
  </custom-marker>
</map>

The error seems to have something to do with cust.category and cust.name, as when I remove these they work fine.

This is the first couple lines of the error message I'm getting:

Watchers fired in the last 5 iterations: [["[ cust.category , cust.name ]; newVal:
[\"pro\",\"Fred\"]; oldVal: [\"pro\",\"Fred\"]","fn: function (context) {\n          
try {\n for(var i = 0, ii = length, part; i<ii; i++) {\n

Full error message here.

Any help with this is appreciated. Thanks in advance!

UPDATE

Code for the custom-marker directive that's part of angular-google-maps is here.

like image 902
realph Avatar asked Nov 09 '22 02:11

realph


1 Answers

It seems like the digest cycle is stuck in a loop. Angular has a digest cycle where they watch models (whatever is on $scope) and apply changes to the views if the models change. If in a digest cycle you're executing some function that changes a value again, you're triggering another digest cycle which triggers that same function again, changes a value on the model and triggers an infinite loop of digest cycles.

That said, you might want to add the code for your customMarker directive for answers to be more precise.

like image 91
Timur Ridjanovic Avatar answered Nov 14 '22 23:11

Timur Ridjanovic