Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angularjs

I have an angularjs properties that contain a float that I display like this :

{{fraisDeDep.kilometre}}

The display is : 45,4564
How to display 45,45 without have a function that destroy the binding ?

Does the method working for {{fraisDeDep.kilometre * fraisDeDep.indemniteKilometre *fraisDeDep.allerretour}} ?

like image 759
mcbjam Avatar asked Dec 21 '22 04:12

mcbjam


1 Answers

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

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

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

<div>{{fraisDeDep.kilometre | number}}</div>
like image 165
Michelle Tilley Avatar answered Dec 28 '22 23:12

Michelle Tilley