Skip to content

Instantly share code, notes, and snippets.

@vhogemann
Created May 26, 2017 11:20
Show Gist options
  • Save vhogemann/d6acba7d4d6c598e7e70f0b7055323bd to your computer and use it in GitHub Desktop.
Save vhogemann/d6acba7d4d6c598e7e70f0b7055323bd to your computer and use it in GitHub Desktop.
Iterate over an Object keys using *ngFor
/**
* 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