Update Angular 8
import { Pipe, PipeTransform } from '@angular/core';
import { CurrencyPipe } from '@angular/common';
@Pipe({ name: 'CustomeCurrency' })
export class CustomCurrencyPipe implements PipeTransform {
constructor(private currencyPipe: CurrencyPipe) { }
transform(value: any, currencyCode?: string, display?: string | boolean, digitsInfo?: string, locale?: string): string {
if (value != null)
return this.currencyPipe.transform(value, currencyCode, display, digitsInfo, locale);
return this.currencyPipe.transform(0, currencyCode, display, locale).split('0.00')[0];
}
}
Try this simple custom currency pipe
{{ null | CustomeCurrency }}</p>
import { Pipe, PipeTransform } from '@angular/core';
import { CurrencyPipe } from '@angular/common';
@Pipe({ name: 'CustomeCurrency' })
export class CustomCurrencyPipe implements PipeTransform {
constructor(private currencyPipe: CurrencyPipe) { }
transform(value: any, currency: string, symbol: boolean = false): string {
if (value != null)
return this.currencyPipe.transform(value, currency, symbol);
return this.currencyPipe.transform(0, currency, symbol).split('0.00')[0];
}
}