I want to make a custom currency pipe using the built-in currency pipe. The way I want to use is {{ anyNumber | customCurrency }}. Then inside my customCurrency pipe, I want to use built-in currency pipe. I can decide the parameters to currency pipe based on some logic and don't want to specify locale and other parameters everywhere like {{anyNumber | currency:'USD':false:'1:0-0'}}.
import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'customCurrency' }) export class CustomCurrencyPipe implements PipeTransform { transform(value: any, args?: any): any { const defaultLocale = 'USD'; const showSymbol = false; ......some logic here...... //HOW TO USE CURRENCY PIPE HERE? } }
newone up (you can@Inject(LOCALE_ID)to pass as its constructor argument).