Angular 2 formatting currency BRL format

前端 未结 11 2471
梦毁少年i
梦毁少年i 2021-02-19 14:52

I\'m trying to use pipe to format the price of an item in PT-BR currency format.

Here what i\'m trying to do:

{{statement
11条回答
  •  别那么骄傲
    2021-02-19 15:23

    In App.module.ts

    import { LOCALE_ID } from '@angular/core';// IMPORTANT
    import { registerLocaleData } from '@angular/common';// IMPORTANT
    import localePt from '@angular/common/locales/pt';// IMPORTANT
    registerLocaleData(localePt); // IMPORTANT
    
     providers: [{
        provide: LOCALE_ID, 
        useValue: "pt-BR"
      }],
    

    In your component.html

    {{price | currency: 'BRL' }}
    

提交回复
热议问题