Opening a url in Ionic app

I have a problem with opening a URL in my Ionic application. I want to open a link in the browser but fail to do that. In my view I have the URL. When the user will click the link I expect the browser to launch and open it. It don’t have to be the system browser. The link can open in my app since the only thing it will do is download a pdf file.

<a href="http://websitename.com/DownloadPdf/PDF/{{Number}}">Download Me!</a>

Does anybody know how to do it? I would be grateful.

You can use Cordova InAppBrowser browser for this purpose: http://www.gajotres.net/how-to-launch-external-application-with-ionic-framework/

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    window.open = cordova.InAppBrowser.open('http://websitename.com/DownloadPdf/PDF/somePDF', '_blank', 'location=yes');
}

Or you can open it in a default software, in your case some PDF reader: http://www.gajotres.net/how-to-open-a-file-using-its-default-application-in-ionic-framework/

Thx, I will check this out! So the only way to open an external URL is by installing this plugin? Isn’t there a build in way for Ionic? Like in native? Just curious about this :slight_smile:

It can be done in several ways but InAppBrowser is a standard last few years.

Yeah, it works :slight_smile: However InAppBrowser open my link in system browser (a diffrent browser than the one which wrap my app) and this mean that I cant access the site because of luck of authentication. How can I open the URL in my wrapper (Ionic)?