Search code examples
angularpipeangular-cliangular8

InvalidPipeArgument: 'Missing locale data for the locale "pt-BR".' for pipe 'xl' environment prod Angular


I made a pipe to display monetary value in the Brazilian format. When squeegee everything works normally. However when running in a DEV / Prod environment on azure I get this message. The error also happens when it runs "ng serves --prod".

This is configuration in the module

import { LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localePt from '@angular/common/locales/pt';


registerLocaleData(localePt);


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

PIPE AS HTML

 {{produto.valorAntesPromocao | number:'1.2-2'}}

Error message :

InvalidPipeArgument: 'Missing locale data for the locale "pt-BR".' for pipe 'xl'


Solution

  • Can you try adding this way

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