AngularJS错误:$ rootScope:infdig [英] AngularJS Error: $rootScope:infdig

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

问题描述

发生在AngularJS以下code的误差。

Error occurs in the following code of AngularJS.

test01.js

test01.js

var MyApp = angular.module('moduleName', []);
MyApp.controller('NameCtrl', ['$scope', function ($scope) {
    $scope.list = function() {

        return {"1": {id: 1, name: "aaa"},
                "2": {id: 2, name: "bbb"},
                "3": {id: 3, name: "ccc"}};
    }
}]);

test01.html

test01.html

<div class="container">
    <div class="jumbotron">
        <h2>test01!</h2>
    </div>
    <div ng-controller="NameCtrl">
        <table class="table table-striped">
            <tr ng-repeat="list in list()">
                <td ng-repeat="nake in list">{{nake.id}}</td>
            </tr>
        </table>
    </div>
</div>

错误

Error: [$rootScope:infdig] http://errors.angularjs.org/1.3.1/$rootScope/infdig?p0=10&p1=%5B%5B%22fn%3A…Breturn%20z(e)%3Ff%3Ae%7D%3B%20newVal%3A%2034%3B%20oldVal%3A%2031%22%5D%5D
Uncaught Error: [$rootScope:infdig] http://errors.angularjs.org/1.3.1/$rootScope/infdig?p0=10&p1=%5B%5B%22fn%3A…Breturn%20z(e)%3Ff%3Ae%7D%3B%20newVal%3A%2034%3B%20oldVal%3A%2031%22%5D%5D angular.js:14078

或阵列巢的错误?
原因不明。

Or error of the nest of the array? Cause is unknown.

推荐答案

我觉得用在ngRepeat功能使得angularjs称呼它为每一个找到的元素,使之成为一个无限循环去了。

I think that using a function in ngRepeat makes angularjs call it for every element it finds, making it go in an infinite loop.

您可以做到以下几点:

<table class="table table-striped" ng-init="list = list()">
    <tr ng-repeat="element in list">

所以它是要去工作。
还有一个问题。列表()函数返回一个对象,而不是阵列。
此外,第二ngRepeat,是不是突破了code,但用处不大,因为没有任何嵌套的数组。
这里有一个工作小提琴:
http://jsfiddle.net/5sek867y/2/

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

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