dcsimg
 

Optimize ng-repeat with the Track by Feature in Angular

Tuesday Jan 1st 2019 by Srinath MS

Language: Web, Expertise: Intermediate - See how to use the track by feature to speed up your processes.

Take a look at the following ng-repeat code example:

<div ng-repeat="order in orders">
</div>

This is inefficient, as the DOM is rendered every time the list is written to the page. Add the track by feature, as shown below, by allowing the code to specify the id key instead of creating random ones and slowing the process.

<div ng-repeat="order in orders track by order.orderid ">
</div>
Home
Mobile Site | Full Site