简体   繁体   English

ngRepeat上的Bindonce

[英]Bindonce on ngRepeat

What is the effect of using the native bindonce on an ng-repeat object? 在ng-repeat对象上使用本机bindonce有什么影响? For example: 例如:

ng-repeat="data in ::stuff"

Does this mean every item in 'stuff' has the watcher removed? 这是否意味着观察者已删除了“材料”中的每个项目? Or do you still need to apply bindonce to every child bind in the repeat like this? 还是您仍然需要像这样在重复中对每个子绑定应用bindonce?

<div ng-repeat="data in ::stuff">
  <span ng-bind="::data.thing"></span>
</div>

For data in ::stuff , the array is bound once and a $watcher is not created after bound the first time, and therefore any changes to that array will not update your ng-repeat 's view. 对于data in ::stuff ,数组绑定一次,第一次绑定后不会创建$watcher ,因此对该数组所做的任何更改都不会更新ng-repeat的视图。

However, unless you have ::data.thing changes to individual objects will still be registered. 但是,除非您具有::data.thing ,否则仍将注册对单个对象的更改。 Those watchers belong to the object itself and not the shallow contents of the array. 这些观察者属于对象本身,而不属于数组的浅层内容。

See my plunkr below. 见下面的我的朋克。

 <iframe src="http://embed.plnkr.co/3gbmI2kqd3rT7z0GEyK7/"></iframe> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM