AngularJS | currency Filter

AngularJS currency filter is used to convert a number into a currency format. If no currency format is specified currency filter uses the local currency format.

Syntax:

{{ currency_expression | currency : symbol : fractionSize}}

Parameters: It contains two parameters as mentioned above and described below:



  • symbol: It is optional parameter. It is used to specify the currency symbol. The currency symbol can be any character or text.
  • fractionsize: It is optional parameter. It is used to specify the number of decimals.

Example 1: This example displays the number in Indian currency format.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>Currency Filter</title>
          
        <script src=
        </script>
    </head>
      
    <body>
   
        <div ng-app="gfgApp" ng-controller="currencyCntrl">
              
            <h3>
                Currency filter with curreency
                symbol and fraction size.
            </h3>
              
            <p>Amount : {{ amount | currency : "Rs" : 2}}</p>
        </div>
   
        <script>
            var app = angular.module('gfgApp', []);
              
            app.controller('currencyCntrl', function($scope) {
                $scope.amount = 75;
            });
        </script>
    </body>
      
</html>

chevron_right


Output:

Example 2: This example display the number in currency fromat.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>Currency Filter</title>
          
        <script src=
        </script>
    </head>
      
    <body>
   
        <div ng-app="gfgApp" ng-controller="currencyCntrl">
              
            <h3>
                Currency filter without curreency
                symbol and fraction size.
            </h3>
              
            <p>Amount : {{ amount | currency}}</p>
        </div>
   
        <script>
            var app = angular.module('gfgApp', []);
              
            app.controller('currencyCntrl', function($scope) {
                $scope.amount = 38;
            });
        </script>
   
    </body>
</html>

chevron_right


Output:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.