4

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.

2 Answers 2

4

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

The documentation is found here:

https://angular.io/guide/pipes#custom-pipes

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

Angular 2 - Number pipe for scientific notation numbers

0

Number pipe will round the numbers. You can use my formula and create a custom pipe. Example to show 2digit.

let number = 1236.25658
let customDigit = parseInt(number * 100) / 100;
console.log(customDigit) //return 1236.25

Not the answer you're looking for? Browse other questions tagged or ask your own question.