angular.filter.currency

Work In Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Formats a number as a currency (ie $1,234.56).

Usage

In HTML Template Binding

{{ amount_expression | currency }}

In JavaScript

angular.filter.currency(amount);

Parameters

Returns

{string} Formated number.

CSS

ng-format-negative When the value is negative, this css class is applied to the binding making it by default red.

Example

<input type="text" name="amount" value="1234.56"/> <br/> {{amount | currency}} it('should init with 1234.56', function(){ expect(binding('amount | currency')).toBe('$1,234.56'); }); it('should update', function(){ input('amount').enter('-1234'); expect(binding('amount | currency')).toBe('$-1,234.00'); expect(element('.doc-example-live .ng-binding').attr('className')). toMatch(/ng-format-negative/); });