SoFunction
Updated on 2025-04-04

AngularJS uses ng-repeat to report an error [ngRepeat:dupes]

AngularJS uses ng-repeat to report an error

 [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify uniq

ng-repeat error

   
<div ng-init="words = ['University','University','University']" ng-repeat="word in words"> 
  {{word}} 
</div> 

[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys

It was found that it was caused by duplication of the same content, the solution

<div ng-init="words = ['University','University','University']" ng-repeat="word in words track by $index"> 
  {{word}} 
</div> 

Add after ng-repeat

track by $index 

Thank you for reading, I hope it can help you. Thank you for your support for this site!