【发布时间】:2016-06-13 14:14:49
【问题描述】:
我目前正在通过 ng-repeat 向 DOM 添加“行”。 (AngularJS 1.5)
我通过我的$scope 中的一个数组有一个简单的 ng-repeat。我已经这样做了很多次,我从来没有遇到过问题。
这是我的 ng 重复:
<li ng-repeat="row in panelRows track by $index" x-sb-panel-row row-data="row" class="row"></li>
在我的界面中,我添加了 2 个相同的对象,当然,通过添加 track-by,我希望它们被单独处理。
这是我在控制台中打印的对象,来自我的指令 x-sb-panel-row,通过 row-data="row" 传递(使用隔离范围和通过属性 row-data 的 2 路绑定)。
第 1 行:Object {name: "Test carousel (not really a carousel)", subText: "3 x 33%", columns: Array[3], $$hashKey: "object:68"}
第 2 行:Object {name: "Test carousel (not really a carousel)", subText: "3 x 33%", columns: Array[3], $$hashKey: "object:68"}
我的问题是$$hashKey: "object:68",显然使用track-by 应该删除它,但它没有,它为我的对象提供了相同的值。我该如何解决这个问题?
【问题讨论】:
标签: angularjs angularjs-directive angularjs-ng-repeat