Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 115x 13x 16x 16x 1x 1x 15x | import { DecimalPipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'value',
standalone: true,
})
export class ValuePipe implements PipeTransform {
constructor(private decimalPipe: DecimalPipe) {}
transform(value: string | number | undefined , decimalFormat: string = '1.0-2'): string | null{
// Check if the value is a number
Iif (value === undefined){
return '';
}
if (typeof value == "number"){
Eif (!isNaN(value)) {
// Apply Angular's DecimalPipe
return this.decimalPipe.transform(value, decimalFormat);
}
return "";
}
// If it's not a number, return the value as-is
return value;
}
}
|