definma-ui/src/app/object.pipe.ts
2020-07-30 14:23:51 +02:00

16 lines
360 B
TypeScript

import { Pipe, PipeTransform } from '@angular/core';
import omit from 'lodash/omit';
@Pipe({
name: 'object',
pure: true
})
export class ObjectPipe implements PipeTransform {
transform(value: object, omitValue: string[] = []): string {
const res = omit(value, omitValue);
return res && Object.keys(res).length ? JSON.stringify(res) : '';
}
}