Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 Currency Pipe change decimal separator

Hello angular friends,

I'm working on an angular2 app (multiple actually). And I live in the Netherlands.

Currently I'm formatting my currency with the following:

{{someIntegerWithCentsToBeDivided / 100 | currency:'EUR':true:'1.0-2'}}

This displays something like 500 to be Eurosign 5 and 501 to be Eurosign 5.01.

Now we dutchies really like comma's the other way around so does anyone know how to change the . to a ,?

Bonus points if someone knows how to show 5,- optionally when there is no cents. My thoughts now would be to extend the CurrencyPipe

like image 914
Mathijs Segers Avatar asked Apr 26 '16 07:04

Mathijs Segers


1 Answers

you need import that

import { registerLocaleData } from '@angular/common';
import localeIt from '@angular/common/locales/it'
registerLocaleData(localeIt, 'it');

and add that pipe in view

{{ 1000 | currency: 'EUR':'symbol':'.2-2':'it' }}
like image 138
Silvio Troia Avatar answered Oct 04 '22 03:10

Silvio Troia