AngularJs Currency Filter Example

By | 2018-04-01T16:02:27+00:00 October 11th, 2016|angularjs|0 Comments

AngularJs currency filter is used to attach the currency symbol in front of currency.

AngularJs Currency Filter Example :

<!DOCTYPE html>
<meta charset="UTF-8">
<title>Angular Currency Filter Example</title>
<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",
        } ]

<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 ng-repeat="employee in employees">
            <td>{{employee.empName | uppercase}}</td>
            <td>{{employee.empSal | currency}}</td>

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

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment