Ion 2: the download component is not always fired (randomly)

Q) Does anyone know if the download component in Ionic 2 is broken, or am I stupid?

I am trying to use the Download component from Ionic 2 as follows:

let loading = Loading.create({
  content: 'Loading: ',
  duration: 3000
});
nav.present(loading);

Although they are determined to reject themselves, they sometimes seem doubled (i.e. 2 overlays on the screen, a much darker background) and they never quit.

It seems broken to me.

I tried to save the global variable and reject it like this:

  showLoading(nav: NavController) {
    if(!window.loadingOverlays) {
      window.loadingOverlays = [];
    }
    // only ever show one instance of the overlay.
    if(window.loadingOverlays && window.loadingOverlays.length > 0) {
      return;
    }

    let loading = Loading.create({
      content: 'Loading...'
    });
    nav.present(loading);
    window.loadingOverlays.push(loading);
  }

  hideLoading() {
    if(!window.loadingOverlays || window.loadingOverlays.length == 0) { 
      return; 
    }
    window.loadingOverlays.forEach((overlay) => {
      overlay.dismiss();
    });
    window.loadingOverlays = [];
  }

adding to it and manually canceling them, but this has no effect.

+4
source share
1 answer

, , , dismiss() .then() dismiss().

: overlay.dismiss().then(() => { /* PUT YOUR CODE HERE */ })

+5

All Articles