在 ng-repeat 对象上使用 native bindonce 会产生什么效果?例如:
ng-repeat="data in ::stuff"
这是否意味着“stuff”中的每个项目都已删除观察者?或者您仍然需要像这样对重复中的每个子绑定(bind)应用bindonce吗?
<div ng-repeat="data in ::stuff">
<span ng-bind="::data.thing"></span>
</div>
最佳答案
对于::stuff 中的 data
,数组会绑定(bind)一次,并且在第一次绑定(bind)后不会创建 $watcher
,因此对该数组的任何更改都会不更新您的 ng-repeat
的 View 。
但是,除非您有 ::data.thing
对单个对象的更改仍然会被注册。这些观察者属于对象本身,而不是数组的浅层内容。
请参阅下面我的 plunkr。
<iframe src="http://embed.plnkr.co/3gbmI2kqd3rT7z0GEyK7/"></iframe>
关于javascript - ngRepeat 上的绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33740861/