ngRepeat
uses $watchCollection to detect changes in the collection. When a change happens, ngRepeat
then makes the corresponding changes to the DOM:
Duplicates
track by
for any list that may include duplicate values.track by
also speeds up list changes significantly.track by
in this case, you get the error: [ngRepeat:dupes]
$scope.numbers = ['1','1','2','3','4'];
<ul>
<li ng-repeat="n in numbers track by $index">
{{n}}
</li>
</ul>