This is my html
<div ng-app="person" ng-controller="names">
<div ng-repeat="id in ids">
{{id}}
</div>
</div>
This is my script
var persons=angular.module("person",[]);
persons.controller("names",function($scope){
$scope.ids=['vicky','a','c','svicky'];
});
This is working fine as expected working fiddle
But when i change the last element from 'svicky' to 'vicky' it is not working
fiddle which is not working
Why is this happening?
Use track by $index as the console tells you. Fiddle
<div ng-app="person" ng-controller="names">
<div ng-repeat="id in ids track by $index">
{{id}}
</div>
</div>
This is the error you should see in the console with your non-working example:
Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With