【发布时间】:2018-04-20 19:46:59
【问题描述】:
我有一个数字类型的输入字段。当用户输入多个零 (0) 并移动到下一个输入字段时,多个零应该回到单个 0。
我在 plunkr 中尝试过以下代码:https://plnkr.co/edit/dyCp5ZMKOkZvcsw4F8og?p=preview
<input [(ngModel)]="value" type="number" class="form-control" id="valueId"
(ngModelChange)="valuechange($event)">
valuechange(newValue) {
//newValue = newValue.toString().replace(/^0+/, '0');
newValue=parseInt(newValue.toString());
console.log(newValue);
}
【问题讨论】:
-
您的插件有不同的代码,请检查并更新插件
标签: angular2-forms two-way-binding