Does ngRepeat rerender all items after adding an n

2020-07-06 04:51发布

If during execution an item is added to an array that is rendered using ngRepeat, does it redraw all items?

2条回答
太酷不给撩
2楼-- · 2020-07-06 05:38

Since Angular 1.2 we have the 'track by' option which will prevent the repeater from re-rendering all the items.

Example:

ng-repeat="task in tasks track by task.id"

Check out this explanation : http://www.codelord.net/2014/04/15/improving-ng-repeat-performance-with-track-by/

查看更多
Animai°情兽
3楼-- · 2020-07-06 05:40

Yes, all items are redrawn.

In fact, the items may be redrawn at other times as well.

Example: When a value in a parent directive / template is updated. During the '$digest' loop, Angular will evaluate the scope tree and this will cause affected child components to be redrawn.

More information:

查看更多
登录 后发表回答