102
rated 0 times
[
103]
[
1]
/ answers: 1 / hits: 62724
/ 10 Years ago, thu, january 8, 2015, 12:00:00
I have a the following statement in my Javascript controller:
$scope.myList = [0, 1, 0.5, 0.6666666];
My AngularJS template contains the following line:
<div ng-repeat=i in myList>{{i}}</div>
This produces the following HTML output:
<div>0</div>
<div>1</div>
<div>0.5</div>
<div>0.6666666</div>
I want the numbers to be rounded to 2 decimal places. However, I would like to see only significant digits in the output. I don't want to see trailing zeroes. How do I do it? Using {{i | number:2}}
doesn't eliminate trailing zeroes.
More From » html