Getting a currency format pattern from AngularJS filter

僤鯓⒐⒋嵵緔 提交于 2019-11-30 11:51:31

The currency pattern and symbols are just that. It determines how to display a number. It will not convert it from XXX to XXX. You will have to do the converting part based on the current conversion rates.

As far as using the built-in currency formatting, there are multiple ways: in the template, in the code.

In the template:

<div>{{myCurrencyValue | currency:'XXX'}}</div>

In the code:

var formatted = $filter('currency')(myCurrencyValue, 'XXX')

In both cases, 'XXX' is optional [and is symbol] and will use the default currency for current locale

Example: http://jsfiddle.net/TheSharpieOne/N7YuP/

More information can be found here: Currency Docs

UPDATE

Example with ISO 4217 codes using custom filter: http://jsfiddle.net/TheSharpieOne/N7YuP/3/

Note: ISO 4217 doesn't dictate the currency symbols, I used this for symbol reference and mapped them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!