Refactoring inAppBrowser usage



I want the inAppBrowser to open every link in my app. Currently I have it like this, which works but I feel like it can be done in another way to be more efficient, just not sure how (i’m still new to Ionic).

Provider: BrowserHelper: browser.helper.ts

import {Injectable} from '@angular/core';
import {InAppBrowser, InAppBrowserOptions} from '@ionic-native/in-app-browser';

export class BrowserHelper {

    constructor(private inAppBrowser: InAppBrowser) {

    openWebpage(url: string) {
        const options: InAppBrowserOptions = {
            zoom: 'no',
            location: 'yes'

        this.inAppBrowser.create(url, '_blank', options);

I call browserHelper in the constructor of every page… which seems wrong.

constructor(private network: Network, private browserHelper: BrowserHelper, private dataService: DataService) {

and I use it like this in the html.

        <ion-item (click)="this.browserHelper.openWebpage('')">

Can anyone explain how I could do this better?


See this: (second part) Sure this can be applied to the Ionic Native wrapepr as well somehow.