angularjs calling Filter twice with ng-repeat

前端 未结 1 2022
后悔当初
后悔当初 2020-12-06 13:09

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 onl

相关标签:
1条回答
  • 2020-12-06 13:55

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

    0 讨论(0)
提交回复
热议问题