Let's say I have an array of objects and that each object has a unique ID and a text property.
Now, let's say I have a ng-repeat like this one:
Controller
$scope.data = my_arr;
View
<div ng-repeat="for elem in data track by elem.id">
{{ elem.text }}
</div>
Special note on the track by.
What would happen if I assigned a completely new array to the data variable ($scope.data = new_arr;), if the content of this new array:
- is completely identical to the previous one
- it contains 1 new element
- it contais all elements except 1
Will AngularJS be smart enough to:
- not re-render all
divelements - append/insert only the new
divelement to the DOM - hide/delete only the
divthat isn't contained in the new array