Posted On: Feb 22, 2018
For iterating over a collection in Angular 2, the ngFor directive is used which instantiates a template once per item from the collection. If a data needs to be changed at some point in the collection, then a problem occurs because angular cannot keep a track of items in the collection and has no knowledge of the items which were added or deleted. This results in the deletion of all the DOM elements that are associated with the data and are again created. If the collection is big, then it becomes more complicated because a lot of DOM manipulation occurs which are expensive. So, to solve this problem, a trackBy function is used which takes the index and the current item as arguments and returns the unique identifier for this item.
Never Miss an Articles from us.
Angular 2 is a completely revived component-based framework in which an application is a tree of loosely coupled compon..
Angular 2 is a re-written version of Angular1 and not an update. The best way to compare Angular 2 and Angular 1 is by f..
Angular 2 is a platform that encompasses a wide range of capabilities. Some new features were added in Angular 2 which i..