繁体   English   中英

组件中的 Angular Currency 管道

[英]Angular Currency pipe in component

我正在尝试在 component.ts 文件中使用此货币管道。但不会产生相同的结果。

{{ money |currency: 'EUR': 'symbol' : '' : locale}}
this.currencyPipe.transform(money, 'EUR', '', true);
//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

这对我有用。

locale: String;
digitInfo: String
this.currencyPipe.transform(money, 'EUR', 'symbol', digitInfo, locale);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM