I want to create a independent method for loading show and hide so that i can use them across the file or can create service.
I am seeing strange behaviour with loader dismiss()
method of LoadingController
- '@ionic/angular'
.
Working in true condition but on exception it not working, is there any other way to implement same.
Method calling loader function is -
please find the online comment for working and not working mentioned in the `signUser()` function -
async signUser() {
this.loadingFunction('Loading...')
try {
this.fireAuth.auth.signInWithEmailAndPassword(this.user.username, this.user.password).then(response => {
this.loaderDismiss();` ** Working fine here*`
}).catch(error => {
this.loaderDismiss(); `** Not working here **`
if (error.code === "auth/wrong-password")
this.alertFunction(error.message);
else if (error.code === "auth/user-not-found")
this.alertFunction(error.message);
else this.alertFunction(error.message);
})
this.loaderDismiss(); `** Not working here **`
} catch (error) {
this.loaderDismiss(); `** Not working here **`
console.log('something went wrong and its not your fault>>>', error);
if (error.code === "auth/argument-error")
this.alertFunction(error.message);
}
}
all methods are in same TS file -
async loadingFunction(loadmsg) {
this.loader = await this.loadCtrl.create({
message: loadmsg
})
await this.loader.present();
}
async loaderDismiss(){
this.loader = await this.loadCtrl.dismiss();
}