Skip to content

Instantly share code, notes, and snippets.

@omelsoft
Forked from clamarque/object-to-array.pipe.ts
Created November 2, 2018 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omelsoft/3af4066c7326cdc3b37fe9817be50315 to your computer and use it in GitHub Desktop.
Save omelsoft/3af4066c7326cdc3b37fe9817be50315 to your computer and use it in GitHub Desktop.
A pipe for Angular2 - Transform Object to Array
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'keys'})
export class KeysPipe implements PipeTransform {
transform(value, args:string[]) : any {
let keys = [];
for (let key in value) {
keys.push({key: key, value: value[key]});
}
return keys;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment