I am currently attempting to utilize a typescript property known as this.data
with the assistance of the executescript()
method from the InAppBrowser plugin. However, I am encountering an issue where the property is returning undefined instead of 'testdata'
.
At this point, I am unsure whether this approach is appropriate or if there is a mistake in my implementation.
import { Component } from '@angular/core';
import { NavController, LoadingController, NavParams} from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
browser: any;
data = 'testdata';
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public iab: InAppBrowser
) {}
showIAB(){
this.browser = this.iab.create('http://example.com/','_blank','location=no,toolbar=yes,zoom=no,hardwareback=no,EnableViewPortScale=yes,closebuttoncaption=Done')
this.browser.on('loadstop').subscribe(
ev =>{
this.browser.executeScript({
code: `document.getElementById('username-1202').value = this.data;
document.getElementById('user_password-1202').value = '123456';`
})
},
err =>{
}
)
}