ng2-pipes
Version:
Useful angular2 pipes
13 lines (10 loc) • 331 B
text/typescript
import {PipeTransform, Pipe} from '@angular/core';
import GeneralHelper from '../helpers';
({name: 'pluck'})
export class PluckPipe implements PipeTransform {
transform(arr: any, map: string): any[] {
return Array.isArray(arr)
? arr.map(e => GeneralHelper.extractDeepPropertyByMapKey(e, map))
: arr;
}
}