Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular - Limit decimal to two places without rounding off

Tags:

angular

I am using the decimal pipe to limit decimal number to two places:

{{amount | number:'1.2-2'}}

But unfortunately the above pipe rounds off the number. Is there any way I can limit the output to two places after decimal without rounding off the number.

like image 874
Kiran Dash Avatar asked Oct 30 '25 02:10

Kiran Dash


1 Answers

I'd suggest that you write a custom pipe to do this.

The documentation is found here:

Updated docs https://angular.dev/guide/pipes/transform-data

Here is a good example how to use a pipe for formating numbers

Angular 2 - Number pipe for scientific notation numbers

like image 121
tomichel Avatar answered Oct 31 '25 16:10

tomichel