Wednesday, January 24, 2018

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.

[ngRepeat:Dupes]

To resolve this issue we must use track by $index in ng-repeat and rewrite the code as below

[wp-like-lock]

[/wp-like-lock]

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

Tags: , ,
I am Saritha Reddy, a Remote codeigniter,Angularjs Developer. I have 4+ years of strong experience in designing, implementing, Programming and delivering advanced XAMPP ( Apache, MySQL and PHP) Web applications development. I am an Indian national and based Andhra Pradesh,Hyderabad. In addition to providing custom programming and design, I also have extensive experience with Open Source technologies to keep costs down and get websites running with as little fuss and wait as possible.

0 Comments

Leave a Comment