LoadingController dismiss without seTimout?


#1

Hi,

To remove LoadingController, we need to add setTimout to dismiss within 2 to 5 seconds?
I just added and want to dismiss when I get success from API but If I don’t add setTimout sometime it will not dismiss LoadingController.

So I want to get confirmation,please let me know .

Thanks


#2
  this.loading.dismiss();

use this after getting success from api


#3

I already tried this, but it didn’t stop.


#4

You get any errors in the console?


#5

Nop.

Working -
setTimout(()=>{
loader.dismiss();
},2000);

But doesn’t work sometime -
loader.dismiss();


#6

How are you creating the loader? Can you post your code here?


#7

let loading = this.loadingCtrl.create({
content: “Loading…”,
duration:5000
});
loading.present();


#8

I believe the problem is with the duration. Using duration in your case might not be a good idea since you want to dismiss programmatically. Try removing the duration.


#9

If I don’t add then loader sometime will not be dismiss. And I want to be sure at some point that It will be execute ay anyhow in correct way/flow.


#10

I see, but using duration might be what is causing unexpected behavior.
You should use loader.dismiss() in the other parts of your code flow.