I’m working on a simple mobile app using Cordova/Phonegap. The app contains a hyperlink to a web page. It took me a couple of hours to get this to work, although this sounds extremely trivial.

For cli-5.2.0 version of PhoneGap, the solution is simple. Create a hyperlink triggering following javascript. Notice the _system target.

window.open(“https://wikipedia.org”, “_system”);

The caveat: you have to adapt the Cordova whitelist to get this to work, see whitelist documentation. Hereafter you find the extract from my config.xml. Obviously you can tweak the intents to your use cases.

<access origin="*"/><plugin name="cordova-plugin-whitelist"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
<platform name="android">
<allow-intent href="market:*"/>
<platform name="ios">
<allow-intent href="itms:*"/>
<allow-intent href="itms-apps:*"/>

Back in the days, you needed the InAppBrowser plugin for the _system target. For current versions, this is not needed.

Once your custom component takes basic shape, a convenient way to communicate with the outside world is by raising events where the parent component can hook on.

I have a client-list component. Every time the user selects a client, the component raises a select event.

<client-list (select)="selectClient($event)"></client-list>

Inside the client-list…

Tim Van Laer

Olifantenjager, wolkenblazer, vuurwerkmaker, jongleur met 17 kegels, maanwandelaar en waterpasverzamelaar.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store