AngularJS currency Filter (original) (raw)
Last Updated : 08 Aug, 2022
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 `
Currency FilterGeeksforGeeks
AngularJS currency Filter
Currency filter with currency symbol and fraction size.
Amount : {{ amount | currency : "₹" :2}}
<script>
var app = angular.module('gfgApp', []);
app.controller('currencyCntrl', function ($scope) {
$scope.amount = 75.648;
});
</script>
`
Output:
Example 2: This example displays the number in currency format by using the currency filter in AngularJS.
HTML `
Currency FilterGeeksforGeeks
AngularJS Currency Filter
Currency filter without currency symbol and fraction size.
Amount : {{ amount | currency}}
<script>
var app = angular.module('gfgApp', []);
app.controller('currencyCntrl', function ($scope) {
$scope.amount = 38;
});
</script>
`
Output: