ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Potential Issue in loadercontroller

Open anand-ma opened this issue 10 years ago • 5 comments

Short description of the problem:

I create a loader in controller and presenting and dismissing it every time i need, it throws error ORIGINAL EXCEPTION: Attempt to use a destroyed view: detectChanges

What behavior are you expecting?

It should work

In my constructor calling a function with below content

    this.loader = this.loadingController.create({
      content: 'Please wait...',
      spinner: 'bubbles'
    });

loader - class property in my custom function i call

this.loader.present();

and

this.loader.dismiss();

to launch and dismiss the overlay.

Which Ionic Version? 1.x or 2.x

2.x

Run ionic info from terminal/cmd prompt:

Your system information:

Cordova CLI: Not installed Gulp version: CLI version 1.2.2 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.11 Ionic CLI Version: 2.0.0-beta.35 Ionic App Lib Version: 2.0.0-beta.19 OS: Windows 7 SP1 Node Version: v5.5.0

If i call this.loadingController.create every time i want to present a overlay it works. Is this the way it is designed or is this a bug?

anand-ma avatar Aug 18 '16 17:08 anand-ma

Hello! Thanks for opening an issue with us! You are correct, you have to create a new loading component after you dismiss another one. Thanks for using Ionic!

jgw96 avatar Aug 18 '16 18:08 jgw96

@jgw96 What is the difference between dismiss and destroy ? I would expect dismiss() to just dismiss the overlay, only if i call detroy(), i should create a new loader (this.loadingController.create)

anand-ma avatar Aug 18 '16 19:08 anand-ma

@anand-ma Good question! Calling destroy() will simply destroy that component without animating it out and cleaning up etc. Calling dismiss() animates it out and a few other things that are important for navigation. Thanks!

jgw96 avatar Aug 18 '16 19:08 jgw96

dismiss() destroys the component so that it is not sitting in memory the whole time your app is running.

jgw96 avatar Aug 18 '16 19:08 jgw96

@jgw96 thank you. In our application, the use case is such that the overlay is called many times. I believe creating the component every time we use will be expensive. May be we need should have one more method or support dismiss method with one argument that sets a flag? For a general developer, when there is dismiss() and destroy(), its not very intuitive to think that by calling dismiss() the component will be destroyed after animating out.

but thanks anyway, this is super cool response time

anand-ma avatar Aug 18 '16 22:08 anand-ma