Created
May 26, 2017 11:20
-
-
Save vhogemann/d6acba7d4d6c598e7e70f0b7055323bd to your computer and use it in GitHub Desktop.
Iterate over an Object keys using *ngFor
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
/** | |
* Use like *ngFor="let key of ( object | keys )" | |
*/ | |
@Pipe({ name: 'keys', pure: false }) | |
export class KeysPipe implements PipeTransform { | |
transform(value: any, args: any[] = null): any { | |
if(!value) return []; | |
return Object.keys(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment