Constant decimal display with number filter

Hi,

I am trying to user filter in order to display a value with always one decimal so this is the code that I used :
{{ value | number:β€˜1.1-1’}}

The result is something like 1.2, 1.6, 1

But it is not what I expected, I would like 1.2, 1.6, 1.0

I have also tried -> {{ value | number:1}}, and I got the following error: inline template:24:24 caused by: digits.match is not a function

            -> {{ value | number:'1'}} but it is also not working

Is there any remedy for this issue?

Thank you four your time.

Regards,

GaΓ«tan

{{ value.toFixed(1) }}

Should do the trick just fine.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed

3 Likes

Thanks a lot, it works!!! :slight_smile:

1 Like

Glad to hear mate! Keep on coding!