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:

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

Sign up to request clarification or add additional context in comments.

Comments

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.