Angularjs数字格式逗号

Angular js number format comma

我需要将数字格式显示为 Rs。 12,36,762.51 但目前显示为 卢比。 1,236,762.51

我需要更改格式,这就是我在 angular js

中使用的方式
{{total | number:2}}

您可以尝试使用以下货币过滤器来显示正确的逗号分隔值。

{{total | currency:'INR'}}

您可以使用自定义过滤器以及如下所示,这里您可以根据您的使用情况进行修改

var app = angular.module('app', []);

app.controller('totalController', function ($scope) {
    $scope.total = 12345678.00;
});

app.filter('IndiaCurrency', function () {        
    return function (input) {
        if (! isNaN(input)) {
            //var currencySymbol = '₹';
            var currencySymbol = 'Rs.';
            //separe fraction part        
            var result = input.toString().split('.');
            //separate last three digit
            var lastThree = result[0].substring(result[0].length - 3);
            var restNum = result[0].substring(0, result[0].length - 3);
            if (restNum != '')
                lastThree = ',' + lastThree;
                //replace commas at places
            var output = restNum.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
            //handle 0 after franction
            if(result[1]==undefined) {
               result[1] = "00";
            } else if(result[1].length <2) {
               result[1] += "0";
            }
            if (result.length > 1) {
                output += "." + result[1] + "";
            }            
            //Return result with symbol
            return currencySymbol + output;
        }
    }
});
<!DOCTYPE html>
<html ng-app="app">
<head>    
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</head>
<body ng-controller="totalController">
    <h3>{{total | IndiaCurrency}}</h3>
</body>
</html>