在使用no-repeat遍历时出现下图中的情况:
<ul>
<li class="repeatli" ng-repeat="i in CrossLineConfig.triggerList.triggerRec.recList">
<input type="checkbox" ng-model="i.enable">
<span>A{{i.id}}</span>
</ul>
$$hashkey??
我之前没见过这个,就查阅网上资料,发现这是一个no-repeat中常见的问题。
解决方法:
<ul>
<li class="repeatli" ng-repeat="i in CrossLineConfig.triggerList.triggerRec.recList track by i.id">
<input type="checkbox" ng-model="i.enable">
<span>A{{i.id}}</span>
</ul>
这是一个有点坑的地方,不过以后记着加上track by 问题就不大了…
主要是因为ng-repeat不能循环重复的对象。
hack: ng-repeat="thing in things track by $id($index)"