AngularJs currency filter is used to attach the currency symbol in front of currency.
AngularJs Currency Filter Example :
[html]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Angular Currency Filter Example</title>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module("myApp", []);
app.controller("employeeCotroller", function($scope) {
$scope.employees = [ {
empId : 1001,
empName : "chandra shekhar",
empSal : "570",
}, {
empId : 1002,
empName : "scott",
empSal : "750",
}, {
empId : 1003,
empName : "mark",
empSal : "600",
} ]
})
</script>
</head>
<body ng-app="myApp">
<h1>Employee Information</h1>
<table ng-controller="employeeCotroller" border="2">
<tr style="background-color: green">
<td>Employee Id</td>
<td>Employee Name</td>
<td>Employee Salary</td>
</tr>
<tr ng-repeat="employee in employees">
<td>{{employee.empId}}</td>
<td>{{employee.empName | uppercase}}</td>
<td>{{employee.empSal | currency}}</td>
</tr>
</table>
</body>
</html>
[/html]
On the above example, we have used the default currency, for this based on the locale you can get the currency in output. For me it is us locale. So that I can get $ sign in front of the currency.
If you want to change the currency type, you can give your currency symbol like below:
{{employee.empSal | currency:'symbol'}}
Output :
Employee Information
Employee Id | Employee Name | Employee Salary |
1001 | CHANDRA SHEKHAR | $570.00 |
1002 | SCOTT | $750.00 |
1003 | MARK | $600.00 |