Angular JS:IE 错误:已达到 10 次 $digest() 迭代.中止 [英] Angular JS: IE Error: 10 $digest() iterations reached. Aborting

查看:17
本文介绍了Angular JS:IE 错误:已达到 10 次 $digest() 迭代.中止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Angular 的新手,我遇到了一个与 IE 相关的问题.

I'm new to Angular and I'm stuck with a issue relating IE.

这是我遇到的 IE 错误.

Here is the IE Error that I'm getting.

Webpage error details

User Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Timestamp: Thu, 13 Dec 2012 04:00:46 UTC


Message: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: function $locationWatch() {\n      var oldUrl = $browser.url();\n\n      if (!changeCounter || oldUrl != $location.absUrl()) {\n\tchangeCounter++;\n\t$rootScope.$evalAsync(function() {\n\t  if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n\t      defaultPrevented) {\n\t    $location.$$parse(oldUrl);\n\t  } else {\n\t    $browser.url($location.absUrl(), $location.$$replace);\n\t    $location.$$replace = false;\n\t    afterLocationChange(oldUrl);\n\t  }\n\t});\n      }\n\n      return changeCounter;\n    }; newVal: 7; oldVal: 6"],["fn: function $locationWatch() {\n      var oldUrl = $browser.url();\n\n      if (!changeCounter || oldUrl != $location.absUrl()) {\n\tchangeCounter++;\n\t$rootScope.$evalAsync(function() {\n\t  if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n\t      defaultPrevented) {\n\t    $location.$$parse(oldUrl);\n\t  } else {\n\t    $browser.url($location.absUrl(), $location.$$replace);\n\t    $location.$$replace = false;\n\t    afterLocationChange(oldUrl);\n\t  }\n\t});\n      }\n\n      return changeCounter;\n    }; newVal: 8; oldVal: 7"],["fn: function $locationWatch() {\n      var oldUrl = $browser.url();\n\n      if (!changeCounter || oldUrl != $location.absUrl()) {\n\tchangeCounter++;\n\t$rootScope.$evalAsync(function() {\n\t  if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n\t      defaultPrevented) {\n\t    $location.$$parse(oldUrl);\n\t  } else {\n\t    $browser.url($location.absUrl(), $location.$$replace);\n\t    $location.$$replace = false;\n\t    afterLocationChange(oldUrl);\n\t  }\n\t});\n      }\n\n      return changeCounter;\n    }; newVal: 9; oldVal: 8"],["fn: function $locationWatch() {\n      var oldUrl = $browser.url();\n\n      if (!changeCounter || oldUrl != $location.absUrl()) {\n\tchangeCounter++;\n\t$rootScope.$evalAsync(function() {\n\t  if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n\t      defaultPrevented) {\n\t    $location.$$parse(oldUrl);\n\t  } else {\n\t    $browser.url($location.absUrl(), $location.$$replace);\n\t    $location.$$replace = false;\n\t    afterLocationChange(oldUrl);\n\t  }\n\t});\n      }\n\n      return changeCounter;\n    }; newVal: 10; oldVal: 9"],["fn: function $locationWatch() {\n      var oldUrl = $browser.url();\n\n      if (!changeCounter || oldUrl != $location.absUrl()) {\n\tchangeCounter++;\n\t$rootScope.$evalAsync(function() {\n\t  if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n\t      defaultPrevented) {\n\t    $location.$$parse(oldUrl);\n\t  } else {\n\t    $browser.url($location.absUrl(), $location.$$replace);\n\t    $location.$$replace = false;\n\t    afterLocationChange(oldUrl);\n\t  }\n\t});\n      }\n\n      return changeCounter;\n    }; newVal: 11; oldVal: 10"]]
Line: 7859
Char: 6
Code: 0
URI: http://localhost:8080/__assets__/lib/angular/angular.js

除了 IE 8 和 IE 9 之外,任何其他浏览器都不会发生这种情况.

This is not happening in any other browser but IE 8 and IE 9.

我有一块手表,正在查看包含位置过滤器的内容过滤对象.

I have a watch looking at a content filtering object which includes a location filter.

我的问题是为什么它不会发生在除 IE 之外的任何其他浏览器上,我应该怎么做才能摆脱这种情况.提前致谢.

My question with this is why doesn't it happen on any other browser but IE and what should I do to get rid of this. Thanks in advance.

推荐答案

我遇到了同样的错误,但看起来是一样的.Chrome\FF 工作正常,但 IE 失败.我点击了应用中的一些链接,有时会出现此错误,有时不会.

I had the same issue with error which looked the same. Chrome\FF worked fine, but IE failed. I've clicked on some links in my app and sometimes got this error and sometimes not.

1) 在我看来,我有几个看起来像这样的链接:

1) In my view I had few links which looked like this:

<a href="#" ng-click="addIP(ip)">Add some IP</a>

2) 这些链接的单击处理程序将新对象添加到 IpRanges 集合中,如下所示:

2) Click handler for those links added new object into IpRanges collection like this:

$scope.IpRanges.push(ip);

3) 集合本身被 ng-repeat 绑定在视图上,我认为 IE 以某种方式无法很好地处理这种情况 - 绑定\添加\应用事件的顺序可能不正确,否则......也是在点击之后在链接上,我在 url 中添加了 # 符号,有时它会闪烁,然后出现错误.所以我删除了 href 属性,一切正常:

3) Collection itself was binded on view by ng-repeat, and I thought that somehow IE could not handle this situation well - probably order of binding\adding\applying events wasn't incorrect or else... Also after click on links I had # symbol added to url, and sometimes it blinked, and then I've got an error. So I removed href attribute and everything worked fine:

<a href="" ng-click="addCurrentIP()">Add as allowed IP</a>

对于类似的情况,可能最好使用 span 或 div.

Probably it's better to use spans or divs for similar situations.

这篇关于Angular JS:IE 错误:已达到 10 次 $digest() 迭代.中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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