I need to format numeric values as follows: If a number has no decimal places consider the value. If you have any decimal place format with 4 digits after the "," or "."
Examples:
Do nothing
40
50Leave as follows
4.4 | 4,40000
7.1 | 7.10000
100.1 | 100.10000
1000.2 | 1000.20000
I tried to create an @Pipe But it didn't work out Follows the code I tried to implement
import { Pipe, PipeTransform } from '@angular/core';
import { DecimalPipe } from '@angular/common'
@Pipe({
name: 'bigInteger'
})
export class BigInteger extends DecimalPipe implements PipeTransform {
transform(value: any, args?: any): any {
const format = args[0] ? '1' : '1.4-4';
let result;
result = super.transform(value, format).toString().replace(",",".");
console.log(result);
return result;
}
}
Html:
<td class="text-center">{{valueOrder | bigInteger: valueOrder > 100}}</td>
What is the best solution to my problem?