LoadingController dismiss without seTimout?

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

  this.loading.dismiss();

use this after getting success from api

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

You get any errors in the console?

Nop.

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

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

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

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

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.

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.

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.