Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Currency Formatter with Comma

Tags:

angularjs

I am using following syntax to format euro amount in angular

{{ 20,00 | currency : "€" : 2}}

what produces

"20.00€"

Is there any simple way to format (using this syntax) the Euro price with comma instead of dot. so like

"20,00€"

?

https://docs.angularjs.org/api/ng/filter/currency

like image 493
Łukasz Rzeszotarski Avatar asked Jul 22 '15 12:07

Łukasz Rzeszotarski


1 Answers

For localisation angular leverages i18n for localization and gloablization of applications. Using the euro symbol will not give you the formatting of comma vs. period.

https://docs.angularjs.org/guide/i18n

You'll need to include the formatting by including the correct i18n script in your project. Here's the example from angular if your application needs german formatting.

<html ng-app>
 <head>
….
   <script src="angular.js"></script>
   <script src="i18n/angular-locale_de-de.js"></script>
….
 </head>
</html>

If you need to format your currency based upon the symbol for the currency though, you'll need to implement a custom filter.

like image 79
mikeswright49 Avatar answered Sep 25 '22 17:09

mikeswright49