Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Js currency, symbol euro after

How to move the symbol euro from the front of the value to after it?

Example:

{{product.price | currency : "€"}} will produce € 12.00

but I would like 12.00 €

like image 217
corsaro Avatar asked Dec 18 '14 13:12

corsaro


People also ask

Does euro sign go before or after?

In Statistics Explained articles the symbol '€' should be used for euro in the text if it is followed by a number. This applies also to graphs and tables. It should be placed before the figure: €30.

How would you display currency and currency symbol of a country in angular?

If you want to display your own name instead of default currency symbol you have to pass display parameter. The display parameter can be “code” (currencycode will be displayed) or “symbol” or “symbol-narrow” or any other custom value.

What is currency filter in Angular JS?

AngularJS currency Filter The currency filter formats a number to a currency format. By default, the locale currency format is used.

Where do you put the currency symbol?

Usage. When writing currency amounts, the location of the symbol varies by language. Many currencies in English-speaking countries and Latin America (except Haiti) place it before the amount (e.g., R$50,00).


2 Answers

You don't have to hack the currency filter!

AngularJS has a great support for i18n/l10n. The currency filter uses the default currency symbol from the locale service and positions it based on the locale settings.

So it's all about supporting and setting the right locale.

<script src="i18n/angular-locale_de-de.js"></script> 

If you are using npm or bower all locales are available via the angular-i18n package.

<span>{{ product.price | currency }}</span> 

will now produce the following output:

65,95 € 

Supporting multiple localizations

If you want to support multiple localizations be careful with the currency symbol as it changes to the default currency of the used locale. But 65,95 € are different to $65,95. Provide the currency symbol as parameter to be safe:

<span>{{ product.price | currency:'€' }}</span> 

In de-de the output would still be 65,95 € but if the location is eg. en-us it would be €65.95 (which is despite some other sayings the correct format to display euro prices in English).

To learn more about angular and i18n/l10n refer to the developer guide.

like image 131
Frederik Kammer Avatar answered Oct 02 '22 16:10

Frederik Kammer


You can't with the currency filter. You could write your own, or just use the number filter.

{{(produce.price | number:2) + "€"}}

like image 32
Reactgular Avatar answered Oct 02 '22 16:10

Reactgular