" 10 $摘要()迭代到达。 !中止"由于使用angularjs过滤 [英] "10 $digest() iterations reached. Aborting!" due to filter using angularjs

查看:110
本文介绍了" 10 $摘要()迭代到达。 !中止"由于使用angularjs过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看看以下内容:

https://dl.dropbox.com/u/4571/musicopeTypescript/musicopeTypescript/index.html

当你输入A,在输入框中,你得到 10 $摘要()迭代到达。中止!错误。

when you type "a" in the input box, you obtain the 10 $digest() iterations reached. Aborting! error.

你有什么想法,为什么出现这种情况?

Do you have any idea, why that happens?

编辑:这里是code,使问题:

Here is the code that makes problems:

http://embed.plnkr.co/PTkvPc

编辑:它看起来是Song.clone的问题。如果我通过angular.copy替换它,然后它的作品。任何人都可以解释一下吗?

It looks like it is a problem of Song.clone. If I replace it by angular.copy, then it works. Anybody could explain that?

下面是工作版本:

http://plnkr.co/edit/8Jk1pR?p=$p$ PVIEW

推荐答案

时,过滤器修改原始数据不知何故?这看起来像它会导致无限循环消化的唯一具体的事情。

Is your filter modifying the original data somehow? That's the only specific thing that looks like it would cause the infinite digest cycle.

修改:在关于不同的克隆功能,导致不同的行为。

EDIT: in regards to different cloning functions lead to different behavior.

我怀疑一个是做深克隆,其他的也没有了,在一种情况下AngularJS是检查对象平等,每次你过滤器创建新的对象,导致了问题。

I suspect one is doing deep cloning, the other is not, and in one case AngularJS is checking object equality and your filter is creating new objects each time, causing the problem.

我建议打破了一些逻辑,或许移动一些入控制器或其他过滤器。这缩小了您的阵列中的过滤器只能这样做,只是恢复到原来的对象的引用。然后,你可以写其他过滤器来操纵标签,等等。

I'd suggest breaking up some of that logic and perhaps moving some of it into the controller or additional filters. The filter that narrows down your array should only be doing that, and just return references to the original objects. Then you can write other filters to manipulate the tags, etc.

此外+1阿爸。 :P

Also +1 for Abba. :P

这篇关于" 10 $摘要()迭代到达。 !中止"由于使用angularjs过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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