@wekas wrote:
I want to close the inAppBrowser window once a certain url has finished loading. User finishes survey.
The code below has the error:
Cannot read property 'close' of undefined
on the line
this.iabRef.close();
Can I not reference this global variable from inside a callback function?
Any ideas?import { Component } from '@angular/core'; import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; declare var cordova: any; @Component({ selector: 'app-tab1', templateUrl: 'tab1.page.html', styleUrls: ['tab1.page.scss'] }) export class Tab1Page { private iabRef; loadStopCounter = 0; constructor(private iab: InAppBrowser) { } buttonClick(link) { console.log('button click'); const target = '_blank'; const options = 'location=yes,zoom=no,hideurlbar=yes,hidenavigationbuttons=yes,closebuttoncaption=Click here to return to App,closebuttoncolor=#f04141'; this.iabRef = cordova.InAppBrowser.open(link, target, options); // this.iabRef.close(); This works!!! this.iabRef.addEventListener('loadstop', this.loadStop); } loadStop(params, callback) { this.loadStopCounter++; if (params.url.substr(params.url.lastIndexOf('/') + 1) === 'formResponse') { // This does not work this.iabRef.close(); } } }
Posts: 1
Participants: 1