小编Vij*_*lik的帖子

Angular 2 - 如何在自定义管道内使用内置管道

我想使用内置货币管道制作自定义货币管道。我想要使​​用的方式是{{ anyNumber | customCurrency }}.然后在我的自定义货币管道中,我想使用内置货币管道。我可以根据某些逻辑决定货币管道的参数,并且不想像{{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?

 }

}
Run Code Online (Sandbox Code Playgroud)

angular-pipe angular2-custom-pipes angular

5
推荐指数
1
解决办法
1万
查看次数