angularjs - How does ng-repeat rendering work under the hood? -
i angularjs rookie. reading guide in angularjs website , confusion.
in angularjs api document ngrepeat
, says:
if working objects have identifier property, should track identifier instead of whole object. should reload data later, ngrepeat not have rebuild dom elements items has rendered, if javascript objects in collection have been substituted new ones. large collections, improves rendering performance. if don't have unique identifier, track $index can provide performance boost.
i don't understand content:
should reload data later, ngrepeat not have rebuild dom elements items has rendered, if javascript objects in collection have been substituted new ones.
what sentence mean? can give me example? thank much!
ngrepeat
behavior changes , without track by
.
when collection changes:
without track by
:
angular rebuild dom (destroy , create again each dom element).
with track by
:
angular retrieve dom element of each item , update values.
as doc said:
for large collections, improves rendering performance.
that behavior explained in this article.
Comments
Post a Comment