Angular formatting currency with a comma

I use the following syntax to format the euro amount in angular

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

what produces

"20.00 €"

Is there an easy way to format (using this syntax) the price of a euro with a semicolon, not a period. so that

"20,00 €"

?

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

+4
source share
2 answers

For localization, angular uses i18n to localize and globalize applications. Using the euro symbol will not give you formatting with a comma or period.

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

You need to enable formatting by including the correct i18n script in your project. Here is an example from angular if your application requires German formatting.

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

, .

+12

$provide.decorator:

app.config(['$provide', function ($provide) {
    $provide.decorator('$locale', ['$delegate', function ($delegate) {
        $delegate.NUMBER_FORMATS.DECIMAL_SEP = ',';
        return $delegate;
    }]);
}]);
+2

Source: https://habr.com/ru/post/1599093/


All Articles