AngularJS Currency



  • Currency filter is one of the AngularJS Filters.
  • It is defined by formats a number as a currency. ($565)
  • The currency filter takes as a default value is locale currency format $.

Syntax:

{ {  currency_expression  | currency : symbol : fractionsize  } }

Parameter Values:

Value Type Description
symbol string It displays the currency symbol. The symbol can be present in some character or text and it is optional.
fractionsize number To round the decimal places in the amount.

Sample coding for currency Filter:

 Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy AngularJS Tutorials</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/
        angular.min.js"> </script>
    </head>
    <body>
        <div ng-app="">
            <h1>currency filter with example</h1>
            <p>The value is $ Symbol:  {{ 200*50 | currency : $}}</p>
            <p>The value in "Nok" Symbol : {{ 105+10 | currency : "NOK" }}</p>
        </div>
    </body>
</html>

currency filter in AngularJS:

<p>The value is $ Symbol:  {{ 200*50 | currency : $}}</p>
<p>The value in "Nok" Symbol : {{ 105+10 | currency : "NOK" }} </p>

The multiplication and addition value will be displays with currency symbol.

Code Explanation for currency Filter:

Code Explanation for AngularJS Currency

  1. The ng-app specifies the root element (<div>) to define AngularJS application.
  2. The expression 200*50 executed and the output will be displayed with $ symbol in <p> tag.
  3. The expression 105+10 executed and the output will be updated “NOK” symbol in <p> tag.

Sample output:

Sample Output for AngularJS Currency

  1. The output displays the multiplication of two numbers with $ symbol
  2. The output displays the addition of two numbers with “NOK” symbol.

AngularJS Filters list:

Filter Description
currency It is used to formats a number as a currency(i.e $589) Current Locale is the default symbol.
date It is used to design a date for specified format.
filter It is used to select a subset of items from an array and it returns the new array.
json It is used to convert a JavaScript object into JSON string.
limitTo It is used to returns an array or a string containing only a specified number of elements
lowercase It is used to converts string to a lowercase.
number It is used to formats a number to a string or text.
orderBy It is used to specify orders an array by an expression
uppercase It is used to converts string to a uppercase.


Related Searches to angularjs currency