I was looking to this answer, and the current version of angular it is possible to define providers for localization and Default currency code.
Like this.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, LOCALE_ID, DEFAULT_CURRENCY_CODE } from '@angular/core';
import localePt from '@angular/common/locales/pt';
import { registerLocaleData } from '@angular/common';
// Register the localization
registerLocaleData(localePt, 'pt-BR');
@NgModule({
declarations: [
AppComponent,
NotificationListComponent
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule,
],
providers: [
{
provide: LOCALE_ID,
useValue: 'pt-BR'
},
{
provide: DEFAULT_CURRENCY_CODE,
useValue: 'BRL'
},
DataService,
NotificationsService,
GeoLocationService,
],
entryComponents: components,
})
Once done, the utilization is very simple:
<div class="col-12" *ngIf="isContentInsurance.value">
<h5 class="pull-left">Gst</h5>
<span class="pull-right">-{{offers.contentInsurance | currency}}</span>
</div>
It is not necessary to create any custom pipeline or different custom action.
import localeDe from '@angular/common/locales/de'; registerLocaleData(localeDe);
– Crown