As I work on developing a small app that launches URLs, I encountered some initial errors such as "CANNOT FIND PLATFORM" and a runtime error regarding module not found. Fortunately, with guidance from the Stack Overflow community, I was able to resolve these issues.
Although the app successfully builds and is visible on real devices, it faces challenges when trying to launch the URL. Clicking the button in Ionic serve triggers a runtime error, preventing the button from functioning properly on actual devices as well.
Included below are excerpts from my .ts and .html files along with a screenshot of the error message:
Home.ts
import {Component} from '@angular/core';
import { Platform } from 'ionic-angular';
declare var cordova:any;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public platform: Platform) {
platform = platform;
}
launch(url) {
this.platform.ready().then(() => {
cordova.InAppBrowser.open(url, "_system", "location=true");
});
}
}
Home.html
<ion-header>
<ion-navbar>
<ion-title>
Home
</ion-title>
</ion-navbar>
</ion-header>
<ion-content class="home">
<p>
<button (click)= "launch('https://www.google.de')"> LAUNCH URL </button>
</p>
</ion-content>