Skip to content

Instantly share code, notes, and snippets.

@schmidt1024
Created April 24, 2017 10:01
Show Gist options
  • Save schmidt1024/04fc879c8baf7913cd5f6d89ac7b4799 to your computer and use it in GitHub Desktop.
Save schmidt1024/04fc879c8baf7913cd5f6d89ac7b4799 to your computer and use it in GitHub Desktop.
angular2 pipe to call the keys of json properties
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'keys'})
export class KeysPipe implements PipeTransform {
transform(value) : any {
let keys = [];
for (let key in value) {
keys.push({key: key, value: value[key]});
}
return keys;
}
}
// <div *ngFor="let property of properties | keys">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment