angular.module("myApp",[])
.controller("myCtrl",function($scope) {
$scope.persons = [{name:"teja",age:11},
{name:"Ash",age:12},
{name:"teja",age:11}];
});
Angular doesn't allow duplicate elements in an array declared in ng-repeat
.
But there is solution "track by $index
" which can allow duplicate elements in array.
Here my question is how ng-repeat
identify there are duplicate elements in the array that is on what factor it identifies.
Whenever a new object is created new reference for that object is created but in the above code how ng-repeat identifies the duplicates.
<div ng-repeat="person in persons">
{{ person.name }}
</div>