Search code examples
angularionic-frameworkionic4inappbrowser

IONIC 4 InAppBrowser hidden until it finishes loading


I am using InAppBrowser IONIC 4 to open a URL from my APP. My problem is that a blank screen appears while the page loads.

How can I give a "loading page" message? There is a way to avoid the blank page

Thank you

This is my code currently.

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',
    });

  }  

}

Solution

  • 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);
      }
    
    }