angular 里$$hashkey问题?

来源:互联网 发布:仙界网络直播间80txt 编辑:程序博客网 时间:2024/05/22 04:38

在使用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键值

$$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)"

0 0
原创粉丝点击