definma-ui/src/app/exists.pipe.ts

14 lines
261 B
TypeScript
Raw Normal View History

2020-07-22 10:45:34 +02:00
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
2021-01-25 12:34:23 +01:00
name: 'exists',
pure: true
2020-07-22 10:45:34 +02:00
})
export class ExistsPipe implements PipeTransform {
2021-01-25 12:34:23 +01:00
transform(value: unknown, key?): unknown {
return value || value === 0 ? (key ? value[key] : value) : '';
}
2020-07-22 10:45:34 +02:00
}