Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70617

[Ionic4] How to properly implement Loading and Alert Controllers

$
0
0

@maciey wrote:

Hello,

I have a method that handles sign in to Firebase. I would like to:

  • display Loading Controller while data is being sent
  • display any errors through Alert Controller, with message: error.message generated by Firebase

How should this be done in Ionic 4?

Here’s my method. Loading Controller seems to be working fine, but I can’t display Alert properly:

async onSignIn() {
    const loading = await this.loadingController.create({
      message: 'Please wait...',
      translucent: true
    });

    const alert = await this.alertController.create({
      header: 'Login Error!',
      subHeader: 'Subtitle',
      message: 'This is an alert message.',
      // message: error.message,
      buttons: ['OK']
    });

    const email = this.signInForm.value.email;
    const password = this.signInForm.value.password;

    this.authService.signin(email, password).then(
      data => {
        loading.dismiss()
          .then(() => {
            this.navController.navigateRoot('');
          });
      },
      error => {
        loading.dismiss()
          .then(() => {
            alert.present();
          });
      }
    );
    loading.present();
  }

Thanks in advance for all hints!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70617

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>