Currency code with i18N - BRL


#1

Hi,

Im trying to use the pipe to format a currency value.
My format is the BRL (with a value of 1500.50 the format should be R$1.500,50).

Im using the folloing code line to format currency:

<h2>VLF: <b> {{v.VLF | currency:'BRL':true:'1.0-0'}}</b></h2>

What is giving me that result:

Should be R$231.682. (period instead of comma).

Any help?
Thanks!


How to apply currency filter to input field?
#2

Hi,

Someone knows why the currency code isn’t working properly?

Thanks!


#3

Hello

I have the same issue, did you solve this ?


#4

Hi Fernandoid!

Sorry but I couldnt fixed this so I made my own method to format currency. I can send you the code if you wants.

Marcílio


#5

Hi Marcillioware

I found this solution that you may put in your app.module.ts

import { LOCALE_ID } from '@angular/core';

    providers: [
        { provide: LOCALE_ID, useValue: 'pt-BR' },

#6

Thank you Fernandoid. I’ll try it on my next project!


#7

import { LOCALE_ID } from ‘@angular/core’;

providers: [
    { provide: LOCALE_ID, useValue: 'pt-BR' },

I try this solution, but no success! It’s like ionic don’t use locale configuration from angular when using pipes like currency or date.


#8

Hi!
Im using this configuration as in your code and its working.

{provide: LOCALE_ID, useValue: "pt-BR"}

Use this to format in HTML.

<h4>Value: <strong>{{var.MyValue | currency :'BRL':true:'1.0-0'}}</strong></h4>