When `$digest()` is called, Angular will loop through all of yours watchers and process each one in turn. Occasionally, the function passed to a watch will update some value (maybe the same thing being watch or something else). When this happens, another `$digest()` cycle is queued.
When this cycle repeats more than 10 times, Angular gives up and spits out an error about infinite digest loops. I don't see anything immediately wrong with your code, but maybe knowing this will help you debug. Also, when in doubt, read Angular's source code! :) Happy Friday! James On Fri, Apr 11, 2014 at 12:01 AM, Sylvain M. <[email protected]>wrote: > Hi, > > I'm having trouble with angularJS and geolocation API (cordova app). > > > $scope.GEOsucces=function(position) > { > var newpos ={ "lat": position.coords.latitude, "lng": > position.coords.longitude, "altitude": position.coords.altitude }; > var newcenter={ "lat": position.coords.latitude, "lng": > position.coords.longitude, "zoom": 15 }; > $scope.$emit('NEW_GPS',newpos, newcenter); > > return false; > }; > > $scope.GEOerreur=function(err) > { > $log.info("GPS error..."); > return false; > }; > > $scope.$on("NEW_GPS", function(event, pos, centre) > { > $scope.$apply(function() > { > $scope.mytrace.path.p2.latlngs.push(pos); > $scope.mytrace.centre.lat = centre.lat; > $scope.mytrace.centre.lng = centre.lng; > }); > $log.info($scope.mytrace); > }); > > GeoLoc = navigator.geolocation.watchPosition($scope.GEOsucces, > $scope.GEOerreur, { maximumAge: 3000, timeout: 10000, enableHighAccuracy: > true}); > > It works for a while and then I get the following error : > > http://errors.angularjs.org/1.2.12/$rootScope/infdig?p0=10&p1=%5B%5B%22fn%3 > …406%2C%5C%22zoom%5C%22%3A13%2C%5C%22autoDiscover%5C%22%3Afalse%7D%22%5D%5D > at http://127.0.0.1:1200/lib/ionic/js/ionic.bundle.js:7548:12 > at Scope.$digest ( > http://127.0.0.1:1200/lib/ionic/js/ionic.bundle.js:19339:19) > at Scope.$apply ( > http://127.0.0.1:1200/lib/ionic/js/ionic.bundle.js:19553:24) > at safeApply ( > http://127.0.0.1:1200/bower_components/angular-leaflet-directive/dist/angular-leaflet-directive.min.js:32:11561 > ) > at Object.<anonymous> ( > http://127.0.0.1:1200/bower_components/angular-leaflet-directive/dist/angular-leaflet-directive.min.js:31:21383 > ) > at o.Mixin.Events.fireEvent ( > http://127.0.0.1:1200/bower_components/leaflet-dist/leaflet.js:6:5055) > at o.Map.Keyboard.o.Handler.extend._onBlur ( > http://127.0.0.1:1200/bower_components/leaflet-dist/leaflet.js:9:8418) > at HTMLDivElement.t.(anonymous function).s [as _leaflet_blur13] ( > http://127.0.0.1:1200/bower_components/leaflet-dist/leaflet.js:8:20284) > ionic.bundle.js:16905 > Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. > Aborting! > Watchers fired in the last 5 iterations: [["fn: parentValueWatch; newVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}; > oldV...<omitted>...5D ionic.bundle.js:7548 > Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! > Watchers fired in the last 5 iterations: [["fn: parentValueWatch; newVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}","center; > newVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}"],["fn: > parentValueWatch; newVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}","center; > newVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}"],["fn: > parentValueWatch; newVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}","center; > newVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}"],["fn: > parentValueWatch; newVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}","center; > newVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}"],["fn: > parentValueWatch; newVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}","center; > newVal: > {\"lat\":43.46768406520923,\"lng\":3.7128639221191406,\"zoom\":13,\"autoDiscover\":false}; > oldVal: > {\"lat\":43.468057820224466,\"lng\":3.715953826904297,\"zoom\":13,\"autoDiscover\":false}"]] > > Any help welcome... > > Best regards, > > Sylvain > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- *James Brewer* *http://www.brwr.org/ <http://www.brwr.org/>* *Software Engineer @ RealScout | What is RealScout? <http://vimeo.com/72791570>* *Twitter* *twitter.com/jamesbrwr <http://twitter.com/jamesbrwr>* *GitHub* *github.com/brwr* <http://github.com/brwr> *StackOverflow** stackoverflow.com/users/2052923/james-brewer <http://stackoverflow.com/users/2052923/james-brewer>* *LinkedIn* *linkedin.com/in/jamesbrwr <http://linkedin.com/in/jamesbrwr>* → *M**y favorite RealScout search is Modern & High-Tech Homes in Atherton <https://kendeleon.realscout.com/categories/modern-high-tech?utf8=%E2%9C%93&loc=Atherton>* -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
