Tuesday, November 24, 2015

Improving ng-repeat Performance with "track by"

Improving ng-repeat Performance with "track by"

track by allows you to specify your own key for ngRepeat to identify objects by, instead of just generating unique IDs.

<ul class="tasks">
  <li ng-class="{done: task.done}" ng-repeat="task in tasks track by task.id">
    {{task.id}}: {{task.title}}
  </li>
</ul>

Reference:

http://www.codelord.net/2014/04/15/improving-ng-repeat-performance-with-track-by/
http://www.codelord.net/2014/05/10/understanding-angulars-magic-dont-bind-to-primitives/
http://moduscreate.com/the-magic-of-angular-js-two-way-binding/

No comments: