我有像54781.7622000、1123.11这样的数值。我希望将它们转换为 $54781.76 和 $1123.11 的格式。
//import currency pipe
import { CurrencyPipe } from '@angular/common'
//initialize in constructor
constructor(private cp: CurrencyPipe)
this.formatedOutputValue = this.cp.transform(parseInt(this.outputValue));
我尝试在这个值后面添加额外的参数,例如。
this.formatedOutputValue = this.cp.transform(parseInt(this.outputValue),1.2-2);
但是不起作用。
this.formatedOutputValue.replace(/.00/g, "")
。 - nash11