Skip to content

Instantly share code, notes, and snippets.

@ko1ebayev
Created March 25, 2022 10:16
Show Gist options
  • Save ko1ebayev/02b8a1f9ffb4fec28e1f0cf24409aef3 to your computer and use it in GitHub Desktop.
Save ko1ebayev/02b8a1f9ffb4fec28e1f0cf24409aef3 to your computer and use it in GitHub Desktop.
Angular utility "trackBy" function
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