# angular.filter.number

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

## Description

Formats a number as text.

If the input is not a number empty string is returned.

## Usage

### In HTML Template Binding

`{{ number_expression | number[:fractionSize] }}`

### In JavaScript

`angular.filter.number(number[, fractionSize])`

### Parameters

- `number – {number|string} –`

  Number to format.

- `fractionSize(optional=2) – {(number|string)} –`

  Number of decimal places to round the number to.

### Returns

`{string}` –

Number rounded to decimalPlaces and places a â,â after each third digit.

## Example

      Enter number: <input name='val' value='1234.56789' /><br/>
      Default formatting: {{val | number}}<br/>
      No fractions: {{val | number:0}}<br/>
      Negative number: {{-val | number:4}}

      it('should format numbers', function(){
        expect(binding('val | number')).toBe('1,234.568');
        expect(binding('val | number:0')).toBe('1,235');
        expect(binding('-val | number:4')).toBe('-1,234.5679');
      });

      it('should update', function(){
        input('val').enter('3374.333');
        expect(binding('val | number')).toBe('3,374.333');
        expect(binding('val | number:0')).toBe('3,374');
        expect(binding('-val | number:4')).toBe('-3,374.3330');
      });