Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular.js - decimal numbers in European notation

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)

like image 635
Richard de Ree Avatar asked May 01 '14 14:05

Richard de Ree


1 Answers

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": ".",
...
like image 180
Dalorzo Avatar answered Oct 27 '22 10:10

Dalorzo