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:

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 =

`` </ 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 =

`` </ 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:

Similar Reads

AngularJS Basics