We all know how to use ng-repeat in Angularjs ,which will acts like loop to display N number of records in a html code. While using ng-repeat directive we will face an error [ngRepeat:Dupes].
Let’s discuss in detail how to resolve this issue, I wrote a service in codeigniter to fetch the database records, and passed to json_encode(); Which will be stored in a angular success function as below example.
Here in the above code, json data is stored in registrations object, let’s Check the html example below how these obj reference is used in ng-repeat.
In the above code we used as
,so if have any duplicate in your data , Duplicate keys are banned because Angularjs uses keys to associate DOM nodes with items. You will get an error as below.
To resolve this issue we must use track by $index in ng-repeat and rewrite the code as below
By using track by $index, which will cause the items to be keyed by their position in the array instead of their value.
Thanks for reading this article