Search code examples
angularpipecurrencyangular2-pipe

Angular 2 currency pipe format


Now i have: <span>{{(price | currency: 'EUR': true)}}</span>

and this outputs with standard format 1,000.00

but i need this format 1.000,00


Solution

  • In AppModule class change locale.

    @NgModule({
      declarations: [
         //
      ],
      imports: [
        //
      ],
      providers: [
        //
      { provide: LOCALE_ID, useValue: "de-DE" }
    
    ],
      bootstrap: [AppComponent]
    })
    export class AppModule { }`
    

    de-DE is just an example, use whatever locale u want.

    More info here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat#Using_locales