0
votes

I am implementing leaflet angular directive. I am getting following error while pushing the markers in $scope.marker .

[$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations:

How to remove this error

  var shorLocationUrl = _baseUrl + "userService/" + "111234567" +"/fetchUserLatLng?userId="+$stateParams.contactId+"&lastNLatLng=5";
     var  responsePromise = $http.get(shorLocationUrl,{ cache: false });

            responsePromise.success(function(data, status, headers, config) {
              console.log(JSON.stringify(data));

                  var latLonglist = data.geolocationList;
                 // console.log(latLonglist[0]);
                  $scope.markers = new Array();
                  for (var i = 0; i < latLonglist.length; i++) {
                    // console.log( geolocationList[i]);
                     //var latLong = latLonglist[i].split(","); 
                     console.log(latLonglist[i].latitude);
                     console.log(latLonglist[i].logitude);

                           $scope.markers.push({

                                lat:Number(latLonglist[i].latitude) ,
                                lng:Number(latLonglist[i].logitude) ,
                                icon: {
                                    iconUrl: 'img/whami.png',
                                    iconSize: [35, 35],
                                    iconAnchor: [40, 80],
                                    popupAnchor: [0, 0],
                                    shadowSize: [0, 0],
                                    shadowAnchor: [0, 0]
                                },
                                focus: true,
                                message:latLonglist[i].tickitSubject,
                                label: {
                                message: "Hey",
                                options: {
                                    noHide: true
                                    }
                               }
                           });


                  };

    //console.log(JSON.stringify($scope.markers));

           })

           responsePromise.error(function(data, status, headers, config) {
            console.log(JSON.stringify(data)); 

           })
1

1 Answers

1
votes

This means angular detected a possible infinite loop. Although the 10 iteration limit can be configured; make sure that you didn't watched and change a model at the same time.

Because when a $digest() is called, all watched listeners are executed; and will loop as needed until there is no more changes in the watched expressions.