definma-ui/src/app/exists.pipe.ts
2020-09-03 15:51:53 +02:00

14 lines
267 B
TypeScript

import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'exists',
pure: true
})
export class ExistsPipe implements PipeTransform {
transform(value: unknown, key?): unknown {
return value || value === 0 ? (key ? value[key] : value) : '';
}
}