加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – Angular如何显示数字总是带有2个小数位

发布时间:2020-12-17 08:09:56 所属栏目:安全 来源:网络整理
导读:我有一个浮点值,我想在 inputgt ;:::2中总是显示2位小数位置的ng模型 input ng-model="myNumb" step ="0.01" type="number" 大多数情况下,当“myNumb”具有十进制时,此功能很有效。但是如果“myNumb”小于2位小数(3.2)或整数(30),则不会强制显示2位小数
我有一个浮点值,我想在< input&gt ;:::2中总是显示2位小数位置的ng模型
<input ng-model="myNumb" step ="0.01" type="number">

大多数情况下,当“myNumb”具有十进制时,此功能很有效。但是如果“myNumb”小于2位小数(3.2)或整数(30),则不会强制显示2位小数。
如何在< input>中强制显示2位小数位。领域

AngularJS – Input number with 2 decimal places它可以帮助…
过滤:
  1. Set the regular expression to validate the input using ng-pattern. Here I want to accept only numbers with a maximum of 2 decimal places and with a dot separator.
<input type="number" name="myDecimal" placeholder="Decimal" ng-model="myDecimal | number : 2" ng-pattern="/^[0-9]+(.[0-9]{1,2})?$/" step="0.01" />

向前看,这是ng-model=”myDecimal | number : 2″的下一个答案。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读