duplicates in a repeater are not allowed

Error : [ngRepeat:dupes] duplicates in a repeater are not allowed.

Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}, Duplicate value: {2}

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

My Problem is - Error: [ngRepeat:dupes] duplicates in a repeater are not allowed.
// this code throws the error "Duplicates in a repeater are not allowed.
// ngRepeater: row in ['Declined By P', 'Quoted By P', 'Quoted By P', 'Declined By P', 'Declined By P']"
<ul>
  <li ng-repeat="row in ['Declined By P', 'Quoted By P', 'Quoted By P', 'Declined By P', 'Declined By P']">
      {{row}}
  </li>
</ul>

AngularJs does not allow duplicates in ng-repeat directive. So I got an error - ngRepeat:dupes

The Solution is - Use 'track by' expression to specify unique keys. See in the below example.

<ul>
    <li ng-repeat="row in ['Declined By P', 'Quoted By P', 'Quoted By P', 'Declined By P', 'Declined By P'] track by $index">
      {{row}}
    </li>
</ul>
 

OR

<div ng-repeat="user in user.userList track by user.UserId">
    {{user.name}}
</div>

Here UserId is unique id and the name of user can be same. So use “track by user.UserId” for ignores error.

See in the AngularJs Official - here: https://docs.angularjs.org/error/ngRepeat/dupes
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.
^