angular - 组件中的角货币管道
问题描述
我正在尝试在 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
推荐阅读
- javascript - 如何强制在浏览器而不是应用程序中打开外部链接?
- c# - 我想在 Xamarin 中制作增量游戏,并且我制作了一些计时器,这些计时器给了我一个异常错误
- google-apps-script - 基于动态和变化的源表创建静态概览表
- java - XSD 到 java bean
- mysql - 有没有更好的方法从 mysql 获取 ISO Ttimestamp?
- haskell - Haskell 实例包装 []
- android - 原因:org.gradle.api.internal.plugins.PluginApplicationException:无法应用插件 [id 'com.android.application']
- php - 如何使用 filepond 发送文件?
- c++ - 如何正确划分方阵?
- python - 一旦达到训练,Keras 就会保存最佳模型