angular.js - decimal numbers in European notation

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 11:00:20

问题


In Angular you can use the currency filter to format a number, like like this:

{{service.price | currency: "€ "}}

the standard output is

€ #,##0.00

How can the output be:

€ #.##0,00

(European notation)


回答1:


Angular supports i18n Standard for location | globalization | internationalization. When it comes to number formatting Angular relies on $locale service and more specifically on the property NUMBER_FORMATS.

The currency symbol by itself will not change the numbering formatting unless you change the 'location'.

Here is the list of locations currently supported by angular:

http://cdnjs.com/libraries/angular-i18n/

Here is an example on how to support german locale:

<html ng-app>
 <head>

   <script src="angular.js"></script>
   <script src="i18n/angular-locale_de-de.js"></script>

 </head>
</html>

If you want to dig more into it you can search for NUMBER_FORMATS in any of the CDNs provided above and you will find what angular will use to format your numbers, this is an example:

"NUMBER_FORMATS": {
    "CURRENCY_SYM": "\u20ac",
    "DECIMAL_SEP": ",",
    "GROUP_SEP": ".",
...


来源:https://stackoverflow.com/questions/23409939/angular-js-decimal-numbers-in-european-notation

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