angularjs调用过滤两次NG-重复 [英] angularjs calling Filter twice with ng-repeat

查看:879
本文介绍了angularjs调用过滤两次NG-重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的 angularjs 和努力学习filters.But的概念在我的情况 angularjs 被调用过滤twice.I期待过滤器,只运行一次,但它的运行两次。无法理解为什么会这样。

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..

这是我的 plunker ...

here is my plunker...

推荐答案

如果我不把你的问题错了,这是同样的问题<一href=\"http://stackoverflow.com/questions/11676901/is-this-normal-for-angularjs-filtering\">here

Angularjs 使用脏检查的方法,所以它需要调用所有的过滤器,看看是否存在任何改变。在此之后就检测到有一个变量(您键入的)的变化,然后重新执行所有的过滤器来检测是否有其他的变化。

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.

要更清醒的认识,计算器这个问题会更详细地专家angularjs解释

To be more clear understanding, stackoverflow this question will explain in more detail by expert in angularjs

这里是另一个plunker相同的调用过滤两次

第一调用是从被检测的变化观察。因为有一个那么他们就需要再次调用,看看是否有消息的变化,因为观察者可以进行更改。

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.

这篇关于angularjs调用过滤两次NG-重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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