“Duplicates in a repeater are not allowed” on ng-repeat

前端 未结 6 2047
野的像风
野的像风 2021-02-05 06:48

I\'ve got the following json data returned from a service request:

{
    \"entries\": [{
        \"id\": 2081,
        \"name\": \"BM\",
        \"niceName\": \"         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 07:09

    Add track by $index to your ng repeat so instead of:

    
    

    Try:

    
    

    There's further information about this in the documentation for this error message:

    Occurs if there are duplicate keys in an ngRepeat expression. Duplicate keys are banned because AngularJS uses keys to associate DOM nodes with items.

    By default, collections are keyed by reference which is desirable for most common models but can be problematic for primitive types that are interned (share references).

提交回复
热议问题