[英]API or angularjs service that gets currency symbol from currency code
I'm looking for a service that when getting the currency code (from a database) will return the currency symbol. 我正在寻找一种服务,当获取货币代码(从数据库)时,将返回货币符号。
Since it could be any country. 既然它可能是任何国家。 I can't just do this :
我不能这样做:
{{product.price | currency: '£' }}
Example : 示例:
{{product.price | currency: 'EUR' }} 200 £
{{product.price | currency: 'USD' }} 200 $
{{product.price | currency: 'LAK' }} 200 ₭
is there any api that do this ? 有没有api这样做? I can't change the database and add 100+ symbols.
我无法更改数据库并添加100多个符号。
You can resolve this by using a simple currency code / symbol map along the lines of: 您可以使用简单的货币代码/符号映射来解决此问题:
currencySymbol = {
'EUR': '€',
'USD': '$',
...
}
then you use it by just referencing currencySymbol['USD']
然后你通过引用
currencySymbol['USD']
使用它
several npm libraries offer you the exact same functionality with a broad list of currency symbols, such as currency-symbol-map 几个npm库为您提供与广泛的货币符号列表完全相同的功能,例如currency-symbol-map
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.