Best practice for LoadingController

Try this and check this works for you… for me this works well…

export class LoginPage {
  loading: any;

  constructor(private loadingCtrl: LoadingController) {
  
      this.loading = this.loadingCtrl.create({
          content: 'Authenticating...'
      });

  }

  login(form) {
       this.loading.present();

     this.auth.loginWithEmail(this.user).then(res => {
        // Successfully logged in
        // now, dismiss the Loading and SetRoot to specific page..
        this.loading.dismiss().then(() => {
             console.log('Login Success', res);
             this.nav.setRoot(HomePage, {}, {animate: true, direction: 'forward'});
        });
     });
   }
}

Let me know if there’s other way to make it more better…

3 Likes