How to return multiple prop from NGFOR trackby function in angular 7?

May 25, 2021


 Return multiple Properties from NGFOR track by function in angular 7.

Multiple Properties from NGFOR track by function in angular 7: 

An optional function passed to the NgForOf instruction that determines how to track changes to the iterable. This function uses iteration index and element ID. Upon delivery, Angular monitors changes in the return value of the function.



We know this is outdated, but I think the problem lies in the way the response of the compare tracker is handled. In your example, you use another object that is always different from another object to answer.
if you are creating an object. you have limited properties and you compare this object to another object then properties are the same but the object is different


we are returned the object JSON.stringify(tricked bj) and if compared to two strings, we needed to change the direction of two boolean values to trigger. 

Properties of ngfor:   





ngfor Directive: The main work of the directive is rendering of the array.



Dom element creating and manipulating the dom structural directives







After executing this code the output is here :



A User with email, work, and username properties. it initializes the user's array property in the forex class. it is used the ngFor directive and every DOM with template expressions: {{user.email}}, {{user.work}} and {{user.username}}.




If we fill out the form and click the Add User button, the input values ​​are summarized and added to the array of users. This component restarts to update the appearance of new records in the user's array.
Rendering arrays in ngFor causes excessive DOM manipulation.
Our example above is too simple to display an in-app delay. Imagine repeating more than 10,000 objects in an array.




Lets Solve the problem using track by:

Differs provides a feature that allows us to provide our own change detection mechanism in the list. Deferred uses a function in trackBy to determine how to recognize changes to items in the list.