import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { ModalController, NavParams } from '@ionic/angular';
import { DomSanitizer } from '@angular/platform-browser';
import * as srcDoc from 'srcdoc-polyfill';


@Component({
    selector: 'app-in-app-browser',
    templateUrl: './in-app-browser.page.html',
    styleUrls: ['./in-app-browser.page.scss'],
})
export class InAppBrowserPage implements OnInit {
    @ViewChild('frame', null)
    public iframe:ElementRef;
    url: any;

    constructor(
        public modalController: ModalController,
        public navParams: NavParams,
        private sanitizer: DomSanitizer
    ) {
        this.url = this.navParams.get('url');
    }

    ngAfterViewInit() {
        // srcDoc.set(this.iframe.nativeElement, this.url);
        this.iframe.nativeElement.src = this.url;
    }

    ngOnInit() {
    }

    back() {
        this.modalController.dismiss();
    }

}
