Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

javascript - Uncaught Error: [$rootScope:infdig]

This is my code snippet

  <tbody ng-repeat="dtataOne in dataOnes()">
      <tr>
          <td>My Data</td>
          <td class="task-container ui-sortable" colspan="6" ng-model="dtataOne.MyModel" ui-sortable="sortableOptions" stafflastname="{{'Pup-Only'}}" data2="{{'999999'}}" task="{{100}}" data3="{{'No'}}">
            <a href="javascript:void(0);"  ng-repeat="tg in Getdata(data3)" ng-click="ShowData(tg)">{{tg.count}}</a>
          </td> 
     </tr>
 </tbody> 

Controller :

  $scope.Getdata = function(data3) {
        var datas = [];       
            data3.forEach(function (staff) {
                if (true) {
                    staff.tgs.forEach(function (tg) {
                        datas.push(tg);
                    });
                } 
        });

        $scope.data3s().forEach(function (datum) {
            if (datum.id === data3.id) {
                datum.MyModel = datas;
            }
        });
        return datas;
    };

In the above code snippet in the line " datum.MyModel = datas;" I am getting an error message like the one mentioned below

Uncaught Error: [$rootScope:infdig] http://errors.angularjs.org/1.2.13/$rootScope/infdig?p0=10&p1=%5B%

Any help will be life saving ....

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

On every digest cycle the function Getdata(data3) will get fired. In that function you are mutating datum.MyModel which kick off an new digest cycle. If this repeats more then 10 times, you get an error.

The short advice: don’t use functions in an ngRepeat expression.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...