【问题标题】:ngModel not update in input type in ionic 3ngModel 没有更新 ionic 3 中的输入类型
【发布时间】:2018-07-21 22:09:15
【问题描述】:

收到 otp 后,输入类型未设置,值未设置

<ion-item>
  <ion-label >OTP Code</ion-label>
   <ion-input type="text" maxlength="4" id="smscode"  minlength="4"
              formControlName="password" placeholder="Your OTP Code"
              value="{{smscode}}"> 
   </ion-input>
</ion-item>
this.smscode=1234;

receiveSMS()
    {
    if(SMS)SMS.startWatch(function(){
    document.addEventListener('onSMSArrive', function(e)
     {
       var sms = e.data;

        if(sms.address=='IM-ODTMLT')
        {  
         this.smscode=sms.body.substr(28,4);
         alert( this.smscode);
         alert(JSON.stringify(sms));
         this.stopSMS();    
         } 
    });

}, 
function()
    {
      console.log('failed to start watching');
    });
}

<ion-input type="text" maxlength="4" id="smscode" minlength="4"
           formControlName="password"
           placeholder="Your OTP Code" value="{{smscode}}">
</ion-input>

这是一个离子代码

【问题讨论】:

  • 这是一个离子代码

标签: angular html ionic-framework ionic3 one-time-password


【解决方案1】:

输入需要ngModel 指令:

<ion-input type="text" maxlength="4" id="smscode" minlength="4"
           formControlName="password" placeholder="Your OTP Code"
           ̶v̶a̶l̶u̶e̶=̶"̶{̶{̶s̶m̶s̶c̶o̶d̶e̶}̶}̶"̶
           [(ngModel)]="smscode">
</ion-input>

【讨论】:

  • 但是在收到短信和 otp 得到但没有更新 ngmodel 之后
猜你喜欢
  • 2020-04-18
  • 2018-06-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-09
  • 1970-01-01
相关资源
最近更新 更多