I have used the number pipe below to limit numbers to two decimal places.
{{ exampleNumber | number : '1.2-2' }}
I was wondering what the logic behind '1.2-2' was? I have played around with these trying to achieve a pipe which filters to zero decimal places but to no avail.
'1.0-0' will give you zero decimal places i.e. no decimals. e.g.$500
Regarding your first question.The pipe works as follows:
numberValue | number: {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
minFractionDigits: Minimum number of integer digits to show after the decimal point
maxFractionDigits: Maximum number of integer digits to show after the decimal point
2.Regarding your second question, Filter to zero decimal places as follows:
{{ numberValue | number: '1.0-0' }}
For further reading, checkout the following blog
From the DOCS
Formats a number as text. Group sizing and separator and other locale-specific configurations are based on the active locale.
SYNTAX:
number_expression | number[:digitInfo[:locale]]
where expression
is a number:
digitInfo
is a string which has a following format:
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
Source: Stackoverflow.com