About InAppBrowser


I’m working on a directive who display some content sent by a wysiwyg, so with links inside

I’ve tried to using InAppBrowser

import { Component, ElementRef, Input, AfterViewChecked } from '@angular/core';

import { InAppBrowser } from 'ionic-native';

  selector: 'wysiwyg-html',
  template: '<div [innerHTML]="content"></div>',
  providers: [ InAppBrowser ]
export class WysiwygHtml implements AfterViewChecked {
    private elem: HTMLElement;

        private inAppBrowser: InAppBrowser,
        private el: ElementRef
    ) {
        this.elem = el.nativeElement;

    @Input('content') content: string;

    ngAfterViewChecked() {
        const links = this.elem.querySelectorAll('a[href]');

        [].forEach.call(links, link => link.onclick = (event) => {

            const target: HTMLLinkElement = event.target;

            this.inAppBrowser.open(target.href, '_system', 'location=true');

But during the build i get TypeScript error: /app/components/wysiwyg-html/wysiwyg-html.ts(30,31): Error TS2339: Property 'open' does not exist on type 'InAppBrowser'.

How is it possible, if i replace this.inAppBrowser with InAppBrowser directly, it doesn’t trigger the error.


Maybe the open method is static?


i’ve had to do this still

window.open(target.href, '_system', 'location=yes');


After some search, it seem that you doesn’t have to instanciate InAppBrowser, and have to call it “as is”
InAppBrowser.open(target.href, '_system', 'location=true');


The syntax for Ionic 2 Native InAppBrowser is here: