Using Angular I ve this in my component
export class AppComponent {
currency = 'EUR';
amount = 312.562;
I want to display my amount with my currency in this format within my template
312.562 -> €000,000,312.562
i ve tried this :
{{ amount | number: '9.2' | currency: this.currency }}
But i ve this error
Error: InvalidPipeArgument: '000,000,312.562 is not a number' for pipe 'CurrencyPipe'
So , how may i juste preppend the currency symbol without treating it as a valid number ?
Suggestions ?
CodePudding user response:
The currency pipe works with some further parameter as you can see from its signature:
transform(
value: number|string|null|undefined, currencyCode: string = this._defaultCurrencyCode,
display: 'code'|'symbol'|'symbol-narrow'|string|boolean = 'symbol', digitsInfo?: string,
locale?: string)
So you could simply use the following in your template:
{{ amount | currency: this.currency:'symbol':'9.3' }}
(I am not sure if you really want 9.2 or 9.3, but initially you said you would want to have this €000,000,312.562. So it would be 9.3)