Simple One way binding for ng-repeat?

前端 未结 4 573
渐次进展
渐次进展 2020-12-28 13:49

I have read some articles that said ng-repeat would led to poor performance if there is over 2000 items, because there are too many two way binding to watch. I am new to ang

4条回答
  •  爱一瞬间的悲伤
    2020-12-28 14:29

    Like user1843640 mentioned, if you are on Angular 1.3, you can use one-time-binding, but, just for clarity, you need to put the :: on all the bindings, not just the repeater. The docs say do this:

    {{item.name}}

    But, if I count the watchers, this only removed one. To really drop the number of two-way-bindings, place the :: on the bindings within the repeater, like this:

    {{::item.name}}

    Here are two plunkers that will display the number of watchers:

    All Bindings
    Repeater Only

    Thanks goes out to Miraage for provinding the function to count the watchers https://stackoverflow.com/a/23470578/2200446

提交回复
热议问题