Angular 以编程方式使用CurrencyPipe

Angular 以编程方式使用CurrencyPipe,angular,pipe,Angular,Pipe,对于行new CurrencyPipe(),我得到错误“提供的参数与调用目标的任何签名都不匹配” 有没有办法以编程方式应用内置管道?上面的代码有什么问题 谢谢。似乎您需要提供区域设置。选中此复选框,另请参见示例 import { Pipe, PipeTransform } from '@angular/core'; import { DecimalPipe, PercentPipe, CurrencyPipe } from '@angular/common'; class myClass{

对于行
new CurrencyPipe(),我得到错误“提供的参数与调用目标的任何签名都不匹配”

有没有办法以编程方式应用内置管道?上面的代码有什么问题


谢谢。

似乎您需要提供区域设置。选中此复选框,另请参见示例
import { Pipe, PipeTransform  } from '@angular/core';
import { DecimalPipe, PercentPipe, CurrencyPipe } from '@angular/common';

class myClass{
   formattedData( value:string){
      let  moneyPipe = new CurrencyPipe();
      moneyPipe.transform( value, 'USD', true );
   }
}