ng-repeat not working over collections that contains dupes

前端 未结 3 791
渐次进展
渐次进展 2020-12-18 21:45

The following code is not working because the collection contains dupes:

I think that

3条回答
  •  再見小時候
    2020-12-18 22:22

    One thing you can do is add "track by $index" as in angular documentation which will change the tracking logic to index of the element rather than value of the element, but this will display the repeated values. To display only unique values you can filter out the unique values by writing a function like :

        var uniqueValues = function(data){
            var check = {};
            var uniqueValue = [];
            for(i-0;i

    and then do a ng-repeat on this.

提交回复
热议问题