Invalid currency format

In my angular 4 project, I want to display some Italian amulets, so I use the standard currency channel, for example: {{amount | currency:'EUR':true}}

But it shows a number formatted as follows: €12.00which is not an Italian standard, I expect something like:€12,00

As I see in the documentation , the channel depends on the i18n API and browser-support is supported in my browser (I use the latest chrome)

Using this: providers: [{provide: LOCALE_ID, useValue: 'it-IT'}] format the currency correctly, but I do not want LOCALE by default.

So why does this channel not automatically understand LOCALE?

+4
source share
1 answer

Create a new handset 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;
    }
}
Run codeHide result

{{amount | CurrencyFilter}}

-1

Source: https://habr.com/ru/post/1687070/


All Articles