ng-repeat無法顯示重複元素的解法
<p ng-repeat="num in [1,1,1]">{{num}}</p>
會出現ERROR訊息"duplicates in a repeater are not allowed",
因為ng-repeat不允許重複元素。
解決方法
<p ng-repeat="num in [1,1,1] track by $index">{{num}}</p>
1
1
1
<p ng-repeat="num in [1,1,1]">{{num}}</p>
會出現ERROR訊息"duplicates in a repeater are not allowed",
因為ng-repeat不允許重複元素。
<p ng-repeat="num in [1,1,1] track by $index">{{num}}</p>
1
1
1
留言
張貼留言