Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

Unable to bind a value from document.addEventListener

$
0
0

@dipankar123 wrote:

hello guys,
i have implemented auto read sms on smsArrived
but unable to bind this OTP in ngmodel
here is my code

watchNewSMS() {
    this.platform.ready().then((readySource) => {
      if (SMS) SMS.startWatch(() => {
        console.log('watching started');
      }, Error => {
        console.log('failed to start watching');
      });
      document.addEventListener('onSMSArrive', function (e: any) {
        if (e.data.address == 'test') {
          console.log(JSON.stringify(e.data))
          let sms = e.data.body
          let otp = sms.split('Your password reset code is ')[1].split('.')[0]
            this.model_autoCapturedOtp = sms.split('Your password reset code is ')[1].split('.')[0]
            console.log(this.model_autoCapturedOtp)    // <--successfull
        }
      });

    });
  }

in html

<ion-item *ngIf="!autoOTPCaptured">
  <ion-input [(ngModel)]="model_autoCapturedOtp" placeholder='Recovery Code'>
</ion-input>

but in html page value not showing

please help

thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles