5

In my angular 4 project I want to display some italian amouts, so I am using the default standard currency pipe like: {{amount | currency:'EUR':true}}

But it shows a number formatted like this: €12.00 that is not the italian standard, I expect something like : €12,00

As I see in the documentation the pipe depends from i18n API and in my browser is supported browser-support ( I am using chrome latest)

Using this : providers: [{provide: LOCALE_ID, useValue: 'it-IT'}] formats correctly the currency but I don't want a default LOCALE.

So Why this pipe don't understand automatically the LOCALE?

Alessandro Celeghin
  • 4,039
  • 14
  • 49
  • 95

1 Answers1

-1

Create a new Pipe like this

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
    name: 'CurrencyFilter',
    pure: false
})
export class CurrencyFilterPipe implements PipeTransform {
    transform(items: number): any {
        var OrigionalValue = items;
        var stringValue = OrigionalValue.toString(); // to get comma we must convert it to string 
        var CommaValue = stringValue.replace('.', ',');
        var finalValue = "€" + CommaValue;
        return finalValue;
    }
}

{{amount | CurrencyFilter}}

Manoj Meria
  • 586
  • 6
  • 13