Open In App

AngularJS currency Filter

Last Updated : 08 Aug, 2022
Suggest changes
Share
Like Article
Like
Report

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 2 parameters as mentioned above and described below: 

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

Example 1: This example displays the number in Indian currency format with two decimals by using the currency filter in AngularJS.

HTML
<!DOCTYPE html> <html> <head> <title>Currency Filter</title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">  </script> </head> <body style="text-align: center;"> <h1 style="color:green">GeeksforGeeks</h1> <h3>AngularJS currency Filter</h3> <div ng-app="gfgApp" ng-controller="currencyCntrl"> <h3> Currency filter with currency symbol and fraction size. </h3> <p>Amount : {{ amount | currency : "₹" :2}}</p> </div> <script>  var app = angular.module('gfgApp', []);  app.controller('currencyCntrl', function ($scope) {  $scope.amount = 75.648;  });  </script> </body> </html> 

Output:

 

Example 2: This example displays the number in currency format by using the currency filter in AngularJS.

HTML
<!DOCTYPE html> <html> <head> <title>Currency Filter</title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">  </script> </head> <body style="text-align: center;"> <h1 style="color:green">GeeksforGeeks</h1> <h3>AngularJS Currency Filter</h3> <div ng-app="gfgApp" ng-controller="currencyCntrl"> <h3> Currency filter without currency 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> 

Output:

 

Explore