angular 数据内容有重复时不显示问题

<body ng-app="app">
    <div ng-controller="myctl">
        <ul>
            <li ng-repeat="item in arr">
                {{item}}
            </li>
        </ul>
    </div>

    <script>
        angular.module("app", []).controller("myctl", function ($scope, $http) {
            $scope.arr = ["dd", "aa", "cc", "aa"];
        });
    </script>
</body>

 arr中有字符串"aa"重复,angular无法显示重复,想要显示可以加上:track by $index

<li ng-repeat="item in arr track by $index">

 

posted @ 2017-05-30 21:10  lunawzh  阅读(609)  评论(0编辑  收藏  举报