admin管理员组文章数量:1319023
I am new to angularjs
and trying to learn concept of filters.But in my case angularjs
is calling the filter twice.I was expecting filter to run only once but its running twice. Cant understand why this is happening..
here is my plunker...
I am new to angularjs
and trying to learn concept of filters.But in my case angularjs
is calling the filter twice.I was expecting filter to run only once but its running twice. Cant understand why this is happening..
here is my plunker...
Share Improve this question edited Dec 27, 2013 at 10:00 Sujith PS 4,8643 gold badges37 silver badges61 bronze badges asked Dec 27, 2013 at 9:58 SemperFiSemperFi 2,3786 gold badges34 silver badges52 bronze badges 4- What do you expect your output to be? I don't understand the question. – Amal Antony Commented Dec 27, 2013 at 10:10
- @AmalAntony: i am just checking out filters while doing so i am getting the issue that filter is getting twice. – SemperFi Commented Dec 27, 2013 at 10:11
-
3
The filter is getting called twice because there are 2 elements in your model (i.e
$scope.actors
). The filter is called once for each element. Does that clarify your problem? – Amal Antony Commented Dec 27, 2013 at 10:13 - possible duplicate of Expression evaluated 2 times – Stewie Commented Dec 27, 2013 at 12:13
1 Answer
Reset to default 6If i don't take your question wrong, this is the same question as here
Angularjs uses a 'dirty-check' approach, so it need to call all the filters to see if exists any change. After this it detect that have a change on one variable(the one that you typed) and then it execute all filters again to detect if has other changes.
To be more clear understanding, stackoverflow this question will explain in more detail by expert in angularjs
Here is another plunker same calling filter twice
The first call is from the watchers that are detecting the change. Because there is one then they need to be called again to see if is there news changes because a watcher can make changes.
本文标签: javascriptangularjs calling Filter twice with ngrepeatStack Overflow
版权声明:本文标题:javascript - angularjs calling Filter twice with ng-repeat - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742050468a2418039.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论