I used \"Ionic Loading Controller\" to show a spinner until the data is retrieved then it calls \"dismiss()\" to dismissed it. it works fine, but sometimes when the app alre
I know this question is to ask about a year ago. I facing the same problem. I just want to post my solution. I hope the upcoming visitor will get help.
async dismissLoading() {
console.log("dismiss");
this.isLoading = false;
}
private async presentLoading(msg) {
console.log("loading");
const loading = await this.loadingCtrl.create({
message: msg,
});
await loading.present();
var timer = setInterval(() => {
if (!this.isLoading) {
loading.dismiss();
clearInterval(timer);
console.log("set dismiss");
}
}, 1000);
}
async loadingmsg() {
this.isLoading = true;
await this.presentLoading("Please wait while...");
}
this solution work for me. Please correct me if I am wrong.