How to open a link in externally (in system browser) in ionic

Step 1

Run the below commands in the root folder of the project

ionic cordova plugin add cordova-plugin-inappbrowser
npm install @ionic-native/in-app-browser



Step 2

Add the below two lines to app.module.ts

//first line
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; 

........


providers: [
    //second line
    InAppBrowser,
    .....

]


Step 3

In the page.ts file add below code

//first line
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; 

........

constructor(
//second line
private iab: InAppBrowser,
....
)

//third line - code to open link in system browser(ex: chrome, firefox)
let browser = this.iab.create("https://webgrid.in", "_system");
browser.show();  



Tagged:
Sign In or Register to comment.