Answer the question
In order to leave comments, you need to log in
How to display the symbol of any currency through currency?
Good day,
There is an output of information through *ngFor to a table where there are currencies. The output is the following:
<td>{{total.sum | currency: total.currency_code : true : '.2'}}</td>
Answer the question
In order to leave comments, you need to log in
In Angular2, the currency pipe ultimately executes this function
https://developer.mozilla.org/en/docs/Web/JavaScri...
For the pipe to return the Russian ruble symbol. he needs to substitute the correct ru-RU locale. It can be overridden globally, but since you use different quotes, you can make a custom pipe
. For example, this is how it can work ( Plunker ):
import { CurrencyPipe } from '@angular/common';
const map = {
'RUB': 'ru-RU',
'JPY': 'ja-JP'
}
@Pipe({name: 'localizedCurrency'})
export class LocalizedCurrencyPipe implements PipeTransform {
transform(value: any, currencyCode: string = 'USD',
symbolDisplay: boolean = false, digits: string = null): string {
return new CurrencyPipe(map[currencyCode]).transform(value, currencyCode, symbolDisplay, digits);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question