在angular中使用ng-repeat时数组中有重复元素,要用item in items track by $index

在angular中使用ng-repeat时数组中有重复元素,要用item in items track by $index,不然会报错

<div class="" ng-init="names=[1,2,3,4,5,5]">
    <p>循环对象:</p>
    <ul>
    <li ng-repeat="x in names track by $index">
    {{ x }}</li>
    </ul>

  </div>

  <script type="text/javascript">
  var app=angular.module('myApp',[]);

  </script>
此文仅为鄙人学习笔记之用,朋友你来了,如有不明白或者建议又或者想给我指点一二,请私信我。liuw_flexi@163.com/QQ群:582039935. 我的gitHub: (学习代码都在gitHub) https://github.com/nwgdegitHub/
原文地址:https://www.cnblogs.com/liuw-flexi/p/12083598.html