特殊input框需求,粘贴文字或者扫码筛选检查后加密为password格式,否则正常显示/假如用户输入的信息是以mima开头,就切换输入框为密码类型

1.angular8粘贴文字或者扫码筛选检查后加密为password格式,否则正常显示

<input [type]="myInputType" (keyup.enter)="getData($event)" nz-input [(ngModel)]="myInputVal" name="myInputVal" #myInput>



@Input('myInputVal')
//  假如用户输入的信息是以mima开头,就切换输入框为密码类型
  set myInputVal(value: string) {
    if (value.indexOf('mima') === 0) {
      this.myInputType = 'password'
    } else {
      this.myInputType = 'text'
    }
 }
posted @ 2021-02-16 18:47  糖~豆豆  阅读(97)  评论(0编辑  收藏  举报
Live2D