添加新项目后 ngRepeat 会重新渲染所有项目吗? [英] Does ngRepeat rerender all items after adding an new item?

查看:21
本文介绍了添加新项目后 ngRepeat 会重新渲染所有项目吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在执行期间将一个项目添加到使用 ngRepeat 呈现的数组中,它是否会重绘所有项目?

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

推荐答案

从 Angular 1.2 开始,我们就有了 'track by' 选项,可以防止转发器重新渲染所有项目.

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

示例:

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

看看这个解释:http://www.codelord.net/2014/04/15/improving-ng-repeat-performance-with-track-by/

这篇关于添加新项目后 ngRepeat 会重新渲染所有项目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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