在input输入框中添加 οnkeyup=”value=value.replace(/[^\d]/g,”)”
栗子:
<input type="text" [(ngModel)]="username" class="form-control input-underline input-lg" formControlName="username" placeholder= "{{ 'PhoneNumber' | translate}}" onkeyup="value=value.replace(/[^\d]/g,'')" autofocus>