Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the currency symbol to the right in Angular

I have to display Euro currency like this : 583 €.

But with this code:

{{ price | currency:'EUR':true }} 

I get €583, is there any option in Angular core to move the symbol to right? A lot of european countries use the symbol at the right (France, Germany, Spain, Italy).

like image 331
Ekaitz Hernandez Troyas Avatar asked Sep 22 '16 08:09

Ekaitz Hernandez Troyas


People also ask

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

Angular Currency Pipe without symbol 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 the default value of symbolDisplay while using the Currencypipe?

The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are "code", "symbol" or "symbol-narrow".


2 Answers

Since Angular2 RC6 version you can set default locale directly in your app module (providers):

import {NgModule, LOCALE_ID} from '@angular/core';  @NgModule({   providers: [{       provide: LOCALE_ID,       useValue: 'de-DE' // 'de-DE' for Germany, 'fr-FR' for France ...     },   ] }) 

Afterwards the currency pipe should pick up the locale settings and move the symbol to right:

@Component({   selector:"my-app",    template:`     <h2>Price:<h2>      {{price|currency:'EUR':true}}   ` }) 
like image 199
benedikt Avatar answered Oct 19 '22 00:10

benedikt


This is working (angular 6) on html side:

{{ amount | currency: 'EUR':'symbol':undefined:'fr-FR' }} 

and on typescript side:

const number = 123456.789; console.log(new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(number)); 

123.456,79 €

like image 24
user1767316 Avatar answered Oct 18 '22 22:10

user1767316