I need to implement the ionic2 loader unless I get a response from firebase


#1

presentLoading() {
let loader = this.loadingCtrl.create({
content: “Please wait…”,
duration: 3000
});
loader.present();
}

loginFirebase() {

this.tempFirebaseData = this.af.auth.login({ email: this.userName, password: this.password },
  { provider: AuthProviders.Password, method: AuthMethods.Password })

return new Promise((resolve, reject) => resolve(this.tempFirebaseData));

}

I am using this code but I dont want a fix duration. I want loader unless I get back a response from firebase.


#2

The login function already return a Promise. Just return this.af.auth.login(...);
Then you can write something like that :

presentLoading() {
  let loader = this.loadingCtrl.create({
    content: "Please wait...",
  });
  loader.present();
  loginFirebase().then((res)=>{loader.dismiss();}, (err)=>{//error})
}

#3

Thank You it works. :smiley: