$ rootScope:infdig 10 $ diffgest()在angularJS中达到了迭代次数

时间:2014-08-18 09:14:04

标签: angularjs leaflet ionic-framework

我正在实现传单角度指令。我在$ scope.marker中推送标记时出现跟随错误。

[$ rootScope:infdig]达到10 $ digest()迭代次数。中止! 观察者在最近5次迭代中被解雇:

如何删除此错误

  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 个答案:

答案 0 :(得分:1)

这意味着角度检测到可能的无限循环。虽然可以配置10次迭代限制;确保您没有同时观看和更改模型。

因为当调用$ digest()时,所有被监视的侦听器都被执行;并将根据需要循环,直到观察到的表达式没有更多变化。