javascript AngularJS:未捕获的错误:[$rootScope:infdig] 已达到 10 个 $digest() 迭代
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26723927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AngularJS: Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached
提问by AlvinJ
I have a nested array which I am ng-repeating on the page. By looking at the page, everything I want to show on the screen is rendered, however in the console I get the error:
我有一个嵌套数组,我在页面上重复它。通过查看页面,我想在屏幕上显示的所有内容都已呈现,但是在控制台中我收到错误消息:
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
I assumed that this error occurs due to the amount of nested array's I have because once I make the size of my nested array smaller, the error doesn't appear.
我认为这个错误是由于我拥有的嵌套数组的数量造成的,因为一旦我缩小了嵌套数组的大小,错误就不会出现。
回答by AlvinJ
So I finally solved the issue. What I ended up doing was adding a library called Recursion Helperto my project, and injected it as a dependency.
所以我终于解决了这个问题。我最终做的是在我的项目中添加一个名为Recursion Helper的库,并将其作为依赖项注入。
Here is a linkto the original post. Thanks!
这是原始帖子的链接。谢谢!
回答by Michael
It is a known AngularJS issue. AngularJS itself prevents to many iterations to avoid infinite loops.
这是一个已知的 AngularJS 问题。AngularJS 本身会阻止多次迭代以避免无限循环。
There is a possible workaround but it can harm other parts of your code:
有一种可能的解决方法,但它可能会损害代码的其他部分:
$rootScopeProvider.digestTtl(15);
This changes the limit of the ten iterations to fifteen or whatever number you would like to.
这会将十次迭代的限制更改为十五或您想要的任何数字。