How to display the currency symbol to the right in Angular

前端 未结 8 1386
花落未央
花落未央 2020-12-15 04:37

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

But with this code:

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

I get

8条回答
  •  伪装坚强ぢ
    2020-12-15 05:02

    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:`
        

    Price:

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

提交回复
热议问题