Improve this Doc View Source

Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default symbol for current locale is used.

## Usage

### In HTML Template Binding

    {{ currency_expression | currency : symbol}}

### In JavaScript

    $filter('currency')(amount, symbol)

### Arguments

Param | Type | Details
--- | --- | ---
amount | number | Input to filter.
symbol (optional) | string | Currency symbol or identifier to be displayed.

### Returns

string | Formatted number.

## Example

Edit in Plunker

    <script>
      angular.module('currencyExample', [])
        .controller('ExampleController', ['$scope', function($scope) {
          $scope.amount = 1234.56;
        }]);
    </script>
    <div ng-controller="ExampleController">
      <input type="number" ng-model="amount"> <br>
      default currency symbol ($): <span id="currency-default">{{amount | currency}}</span><br>
      custom currency identifier (USD$): <span>{{amount | currency:"USD$"}}</span>
    </div>

    it('should init with 1234.56', function() {
      expect(element(by.id('currency-default')).getText()).toBe('$1,234.56');
      expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('USD$1,234.56');
    });
    it('should update', function() {
      if (browser.params.browser == 'safari') {
        // Safari does not understand the minus key. See
        // https://github.com/angular/protractor/issues/481
        return;
      }
      element(by.model('amount')).clear();
      element(by.model('amount')).sendKeys('-1234');
      expect(element(by.id('currency-default')).getText()).toBe('($1,234.00)');
      expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('(USD$1,234.00)');
    });