未捕获的错误:[$rootScope:infdig] [英] Uncaught Error: [$rootScope:infdig]

查看:27
本文介绍了未捕获的错误:[$rootScope:infdig]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码片段

  <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> 

控制器:

  $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;
    };

在上面的代码片段中datum.MyModel = datas;"我收到一条类似下面提到的错误消息

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

未捕获的错误:[$rootScope:infdig] http://errors.angularjs.org/1.2.13/$rootScope/infdig?p0=10&p1=%5B%

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

任何帮助都将挽救生命......

Any help will be life saving ....

推荐答案

在每个摘要循环中,函数 Getdata(data3) 都会被触发.在该函数中,您正在改变 datum.MyModel 以启动新的摘要循环.如果重复超过 10 次,就会出现错误.

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.

简短的建议:不要在 ngRepeat 表达式中使用函数.

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

这篇关于未捕获的错误:[$rootScope:infdig]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆