Angular 9 References/ Templates
References

number (decimal) pipe

This is the documentation for Angular 9.
You can switch to the latest version Angular 10.

Transforms a number into a string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.

Source
<p>e (no formatting): {{e | number}}</p>
<p>e (3.1-5): {{e | number:'3.1-5'}}</p>
<p>e (4.5-5): {{e | number:'4.5-5'}}</p>
<p>pi (no formatting): {{pi | number}}</p>
<p>pi (3.1-5): {{pi | number:'3.1-5'}}</p>
<p>pi (3.5-5): {{pi | number:'3.5-5'}}</p>
<p>-2.5 (1.0-0): {{-2.5 | number:'1.0-0'}}</p>
export class AppComponent {
  e = Math.E;
  pi = Math.PI;
}
Result

e (no formatting): 2.718

e (3.1-5): 002.71828

e (4.5-5): 0,002.71828

pi (no formatting): 3.142

pi (3.1-5): 003.14159

pi (3.5-5): 003.14159

-2.5 (1.0-0): -3

Parameters

{{ value_expression | number [ : digitsInfo [ : locale ] ] }}

digitsInfo#

digitsInfo?: string
Decimal representation options.Specified by a string in the following format: ``` {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits} ``` - `minIntegerDigits`: The minimum number of integer digits before the decimal point. Default is `1`. - `minFractionDigits`: The minimum number of digits after the decimal point. Default is `0`. - `maxFractionDigits`: The maximum number of digits after the decimal point. Default is `3`.

locale#

locale?: string
A locale code for the locale format rules to use.