Last active
July 4, 2022 18:08
-
-
Save gesielrosa/c8e846be9879e580487923a5cc803bc9 to your computer and use it in GitHub Desktop.
Track by pipe for Angular
This file contains 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
import {NgModule, Pipe, PipeTransform} from '@angular/core'; | |
@Pipe({ | |
name: 'trackByKey', | |
pure: true, | |
}) | |
export class TrackByKeyPipe implements PipeTransform { | |
public transform(key: string) { | |
return (index, value) => { | |
return value[key]; | |
}; | |
} | |
} | |
@NgModule({ | |
declarations: [TrackByKeyPipe], | |
exports: [TrackByKeyPipe], | |
}) | |
export class TrackByKeyPipeModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: