Improve this Doc View Source number

From Get docs
< Filter components in ngAngularjs/docs/1.8/api/ng/filter/number


Improve this Doc View Source number

  1. filter in module ng

Overview

Formats a number as text.

If the input is null or undefined, it will just be returned. If the input is infinite (Infinity or -Infinity), the Infinity symbol '∞' or '-∞' is returned, respectively. If the input is not a number an empty string is returned.


Usage

In HTML Template Binding

{{ number_expression | number : fractionSize}}

In JavaScript

$filter('number')(number, fractionSize)

Arguments

Param Type Details
number numberstring Number to format.

fractionSize

(optional)

numberstring Number of decimal places to round the number to. If this is not provided then the fraction size is computed from the current locale's number formatting pattern. In the case of the default locale, it will be 3.


Returns

string Number rounded to fractionSize appropriately formatted based on the current locale (e.g., in the en_US locale it will have "." as the decimal separator and include "," group separators after each third digit).

Example

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
https://code.angularjs.org/1.8.2/docs/api/ng/filter/number