32
loading...
This website collects cookies to deliver better user experience
DecimalPipe
number
{{ value | number [ : digitsInfo [ : locale ] ] }}
Common Module
string
or number
digitsInfo
string
.locale
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
minIntegerDigits
minFractionDigits
maxFractionDigits
pi
and assign the value 3.14159pi = 3.14159;
<h2>Decimal Pipe</h2>
<h4>Without the pipe</h4>
<p>{{ pi }}</p>
<hr />
<h4>Default Decimal Pipe</h4>
<p>{{ pi | number }}</p>
<hr />
pi
without any pipe it shows the entire value. But when we use the decimal pipe the number of digits after decimal becomes 3 and does the rounding off too.digitsInfo
parameter in detail-<h4>digitsInfo Example</h4>
<p>
Here number of digits before decimal is 1. <br>
Minimum number of digits after decimal is 1 <br>
Maximum numberof digits after decimal is 2 <br>
<i>Output- </i>
<b>{{ pi | number: "1.1-2" }}</b>
</p>
<p>
Here number of digits before decimal is 3.
Since the value has only one digit so the remaining
digits are covered by 0.<br>
Minimum number of digits after decimal is 2. <br>
Maximum numberof digits after decimal is 4.
Number of digits shown after decimal is 4. <br>
<i>Output- </i>
<b>{{ pi | number: "3.2-4" }}</b>
</p>
<p>
No digits after the Decimal Point. <br>
<i>Output- </i>
<b>{{ pi | number: "1.0-0" }}</b>
</p>