Ok, here’s the code I used for implementing the plain cordova plugin. I only changed home.ts. The rest is the same as in my original post. I commented the stuff I changed.
home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { Platform } from 'ionic-angular';
// Declaring cordova so we can use it for the plugin
declare var cordova: any;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, private iab: InAppBrowser, private platform: Platform) {
platform.ready().then(() => {
// If we run this in the browser without this if statement we get an error
if (typeof cordova !== 'undefined') {
// Open the InAppBrowser Cordova plugin
const browser = cordova.InAppBrowser.open('https://ionic.io');
// Add the event listener to the InAppBrowser instance
browser.addEventListener('loadstart', function(){
console.log('loadstart!');
});
}
});
}
}
Exactly. So I went for an online searching spree (for days) and the code in my original post is the version I came across the most in threads and examples. I tried all variants I found though, and all of them produced the same Invalid event target error. There being no example in the docs is the whole reason I’m here I guess. I’m posting these threads as a last resort, to find someone who can tell me how to write this or tell me I found a bug.
Thank you very much for your help so far Jan, you’re awesome. So, what’s next?