IONIC 4 InAppBrowser隐藏直到完成加载

时间:2019-06-30 06:54:46

标签: angular ionic-framework ionic4 inappbrowser

我正在使用InAppBrowser IONIC 4从我的APP中打开一个URL。我的问题是页面加载时出现空白屏幕。

如何给“正在加载页面”消息?有一种避免空白页的方法

谢谢

这是我目前的代码。

import { Component } from '@angular/core';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss']
})
export class Tab1Page {

  constructor(private iab: InAppBrowser) {}

    public reportes() {
    var target = "_blank";
    const browser =this.iab.create('google.com.mx',target,{
      location: 'no',zoom: 'no',
    });

  }  

}

1 个答案:

答案 0 :(得分:0)

import { Component } from '@angular/core';
import { LoadingController } from '@ionic/angular';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {

   loaderToShow: any;

  constructor(
    public loadingController: LoadingController
  ) {
  }

  showLoader() {
    this.loaderToShow = this.loadingController.create({
      message: 'This Loader will Not AutoHide'
    }).then((res) => {
      res.present();

      res.onDidDismiss().then((dis) => {
        console.log('Loading dismissed!');
      });
    });
    this.hideLoader();
  }

  hideLoader() {
    setTimeout(() => {
      this.loadingController.dismiss();
    }, 4000);
  }

}