Reputation: 6140
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
Upvotes: 5
Views: 8005
Reputation: 26940
You can overwrite locale options with $provide.decorator
:
app.config(['$provide', function ($provide) {
$provide.decorator('$locale', ['$delegate', function ($delegate) {
$delegate.NUMBER_FORMATS.DECIMAL_SEP = ',';
return $delegate;
}]);
}]);
Upvotes: 3
Reputation: 3416
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.
Upvotes: 13