Angular 5 percent digitInfo handset not working properly

If I do this in an Angular 5 template:

{{0.7 | percent:'1.2-5'}} 

I get it as expected: 70.00%

However, when I do this:

 {{0.07 | percent:'1.2-5'}} 

I get 7.00000% instead of the expected 7.00%

Am I just doing something wrong or is it a bug in Angular?

+5
source share
1 answer

Sounds like a bug with DecimalPipe , because PercentPipe uses it for formatting. A simple removal of maxFractionDigits , which is the maximum number of digits after a fraction (default is 3 ), will give you the desired result:

 {{0.7 | percent:'1.2'}} --> 70.00% {{0.07 | percent:'1.2'}} --> 7.00% 
+2
source

Source: https://habr.com/ru/post/1273895/


All Articles