Issue
I am trying to display a percentage value in my HTML as follows:
<td> {{ ((myvalue/totalvalue)*100) }}%</td>
It works but sometimes it gives a very long decimal which looks weird. How do I round it off to 2 digits after the decimal? Is there a better approach to this?
Solution
You can use the toFixed
method of Number
.
((myValue/totalValue)*100).toFixed(2)
Answered By - Explosion Pills
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.