Is it possible to round a float on a display using CSS or AngularJS?

I have angularjs properties that contain a float, which I show as follows:

{{fraisDeDep.kilometre}} 

Display: 45.4564
How to display 45.45 without a function that destroys the binding?

Is the method used for {{fraisDeDep.kilometre * fraisDeDep.indemniteKilometre * fraisDeDep.allerretour}}?

+4
source share
1 answer

You can use the built-in number filter for this:

 <div>{{fraisDeDep.kilometre | number:2}}</div> 

The default value of fractionSize is 2 , so you can also leave it in this case:

 <div>{{fraisDeDep.kilometre | number}}</div> 
+11
source

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


All Articles