Question

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)

Was it helpful?

Solution

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": ".",
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top