调试$ rootScope:infdig [英] Debugging $rootScope:infdig

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

问题描述

这是一个常见问题:

达到5个$ digest()迭代.流产!
观察者在最近5次迭代中被触发:[]

5 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []

文档( https://docs.angularjs.org/error/ $ rootScope/infdig)说明了为避免这种情况应采取的措施.

The documentation (https://docs.angularjs.org/error/$rootScope/infdig) explains what NOT to do to avoid the situation.

但是,有时您还是会遇到这种情况.对于比玩具应用程序更大的项目,要找到无限摘要循环的原因可能非常困难.

However, once in a while, you end up in the situation anyway. And for a project larger than a toy app, finding the cause of the infinite digest loop can be really hard.

我正在寻找有关如何找出导致循环的代码所在位置的调试提示.

I'm looking for debugging hints on how I can find out where the code is located which causes the loop.

推荐答案

问题已在此处得到解答-如何解决Angular问题" 10已达到$ digest()个迭代次数"错误

question was already answered here - How to Troubleshoot Angular "10 $digest() iterations reached" Error

作为两个最佳答案的简历:

as a resume of two best answers:

  1. 删除所有可疑HTML -基本从模板中删除所有html,并检查是否没有警告( https://stackoverflow.com/a/17116322/274500 )
  1. remove all suspicious HTML - basically remove all your html from the template, and check if there are no warnings (https://stackoverflow.com/a/17129274/274500)
  2. usually it happens when function returns an new object (https://stackoverflow.com/a/17116322/274500)

您始终可以在此处条件断点rel ="noreferrer"> https://github.com/angular/angular.js/blob/c3220325a0a95484724a03bedca24e1bbf05dc80/src/ng/rootScope.js#L815 来检查异常堆栈跟踪.

you can always put conditional breakpoint here https://github.com/angular/angular.js/blob/c3220325a0a95484724a03bedca24e1bbf05dc80/src/ng/rootScope.js#L815 to check the exception stacktrace.

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

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