I need to display this number 2387,15
I am doing this with angularjs :
{{myNumber|number:2}}
I am getting 2,387.15 I dont want a coma betwen 2 and 3 (I am french).
Is there a way to set the locale with angularjs?
Thanks
Approach #1. If you want french locale then you can simply include corresponding localization file. For example:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.4.5/angular-locale_fr-fr.js"></script>
Then Angular will pick it up and use for all localization.
<script src="https://code.angularjs.org/1.4.3/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.4.5/angular-locale_fr-fr.js"></script>
<script>
angular.module('demo', []).controller('mainCtrl', function($scope) {
$scope.myNumber = 2387,15;
});
</script>
<div ng-app="demo" ng-controller="mainCtrl">
{{myNumber|number:2}}
</div>
Approach #2. Another simple thing you can do is to customize NUMBER_FORMATS.GROUP_SEP
constant:
angular.module('demo', []).controller('mainCtrl', function($scope, $locale) {
$locale.NUMBER_FORMATS.GROUP_SEP = ' ';
$scope.myNumber = 2387,15;
});
<script src="https://code.angularjs.org/1.4.3/angular.js"></script>
<div ng-app="demo" ng-controller="mainCtrl">
{{myNumber|number:2}}
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With