Experiencing the same problem with the date, percent, and currency pipes when using them in a template—
For example, I\'m using a simple percent pipe:
Or another solution would be writing those pipes yourself. For the date, for example, you can use moment.js, or here is an example for the currency pipe:
import { Pipe, PipeTransform } from '@angular/core'
@Pipe({ name: 'currency' })
export class CurrencyPipe implements PipeTransform {
constructor() {}
transform(value: string, currencyString: string ) {
let stringOnlyDigits = value.replace(/[^\d.-]/g, '');
let convertedNumber = Number(stringOnlyDigits).toFixed(2);
return convertedNumber + " " + currencyString;
}
}
This pipe is transforming the currency. The percent pipe would work nearly the same way. The regex is filtering all digits including the point for float numbers.