0

How can I change the decimal that by default is 'dot' by a 'comma' in the filter of currency in AngularJS?

Example:

{{10000 | currency}} 10,000.00 ==> 10.000,00

Thanks!

pid
  • 11,472
  • 6
  • 34
  • 63
Leonardo
  • 9
  • 4

1 Answers1

1

Here is a working demo using a decorator, in the configuration block, to modify locale NUMBER_FORMATS properties DECIMAL_SEP and GROUP_SEP. It is called only one time and is valid for any filter that depends on it:

angular
    .module('App', [])
    .config(['$provide', function($provide) {
        $provide.decorator('$locale', ['$delegate', function($delegate) {
            $delegate.NUMBER_FORMATS.DECIMAL_SEP = ',';
            $delegate.NUMBER_FORMATS.GROUP_SEP = '.';
            return $delegate;
        }]);
    }])
    .controller('ExampleController', function($scope) {
        $scope.myNumber = 10000;
    });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="App" ng-controller="ExampleController">
  <p>{{myNumber | currency}}</p>
</div>
Yosvel Quintero
  • 18,669
  • 5
  • 37
  • 46