Angular ng-repeat Error “Duplicates in a repeater are not allowed.”

后端 未结 10 2316
青春惊慌失措
青春惊慌失措 2020-11-22 06:11

I am defining a custom filter like so:

10条回答
  •  伪装坚强ぢ
    2020-11-22 06:50

    The solution is actually described here: http://www.anujgakhar.com/2013/06/15/duplicates-in-a-repeater-are-not-allowed-in-angularjs/

    AngularJS does not allow duplicates in a ng-repeat directive. This means if you are trying to do the following, you will get an error.

    // This code throws the error "Duplicates in a repeater are not allowed.
    // Repeater: row in [1,1,1] key: number:1"
    

    However, changing the above code slightly to define an index to determine uniqueness as below will get it working again.

    // This will work
    

    Official docs are here: https://docs.angularjs.org/error/ngRepeat/dupes

提交回复
热议问题