【问题标题】:Angular Currency pipe in component组件中的角货币管道
【发布时间】:2019-02-19 11:27:55
【问题描述】:
我正在尝试在 component.ts 文件中使用此货币管道。但不会产生相同的结果。
{{ money |currency: 'EUR': 'symbol' : '' : locale}}
this.currencyPipe.transform(money, 'EUR', '', true);
【问题讨论】:
标签:
angular
currency
angular-pipe
【解决方案1】:
//add currency pipe to your constructor in x.ts
private currencyPipe:CurrencyPipe
//add to your providers in app.module or to your child module if you have nested routes.
providers: [CurrencyPipe],
//use the pipe in x.ts as;
let some_money = 3000
let me_converted = this.currencyPipe.transform(some_money, 'Ksh.');
console.log(me_converted); //Ksh.3,000.00
【解决方案2】:
这对我有用。
locale: String;
digitInfo: String
this.currencyPipe.transform(money, 'EUR', 'symbol', digitInfo, locale);