Created
March 25, 2022 10:16
-
-
Save ko1ebayev/02b8a1f9ffb4fec28e1f0cf24409aef3 to your computer and use it in GitHub Desktop.
Angular utility "trackBy" function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function trackBy<T>(propertyPath?: keyof T) { | |
return function(index: number, item: T) { | |
return propertyPath ? get(item, propertyPath, index) : index; | |
}; | |
} | |
export function trackByIdentity<T>(index: number, item: T): T { | |
return item; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment