Yuvanesh Gowtham Yuvanesh Gowtham -4 years ago 164
TypeScript Question

Runtime error:Uncaught(inpromise):reference error:cordova is not defined

I am trying to create a small app which launches URL, at first I got error (CANNOT FIND PLATFORM) and there was runtime error that couldnot find module .,those previous errors were solved with help from experts here. but now the app is successfully build and it is visible in real device but it could not launch the URL. If i click the button in ionic serve , i am geeting runtime error and the button is also not working in real device.
I have added my .ts and.html file and screenshot of the error.Any suggestion would be really helpful. Thank you.

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>


enter image description here

Answer Source

Ensured that InAppBrowser is present in plugin folder. Otherwise add it ionic plugin add cordova-plugin-inappbrowser

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download