admin管理员组文章数量:1391987
I am using ng-bind to bind the value of price
<td><span ng-bind="'$' o.Price"></span></td>
but it is taking value like this 281.96000000000004 so how can I restrict this value in view so it takes only two digits after decimal. like 281.96.
I am using ng-bind to bind the value of price
<td><span ng-bind="'$' o.Price"></span></td>
but it is taking value like this 281.96000000000004 so how can I restrict this value in view so it takes only two digits after decimal. like 281.96.
Share Improve this question edited Aug 14, 2017 at 8:52 AVJT82 73.4k25 gold badges145 silver badges170 bronze badges asked Aug 14, 2017 at 8:51 Gaurav_0093Gaurav_0093 1,0307 gold badges30 silver badges58 bronze badges3 Answers
Reset to default 7use the number
filter
<td><span ng-bind="'$' + (o.Price | number : 2)"></span></td>
You can use the currency filter (if it's a price in dollars):
<td><span>{{ o.Price | currency }}</span></td>
you can use angular filter | number : fractionSize
for two decimal places fractionSize use:
<td><span ng-bind="'$' o.Price| number : 2"></span></td>
本文标签: javascriptHow to use toFixed(2) in ngbind angularjsStack Overflow
版权声明:本文标题:javascript - How to use toFixed(2) in ng-bind angularjs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744646295a2617419.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论