this.navCtrl.push() not working but alerts does

#1

this.navCtrl.push() is not working even though the alerts are. If I put alerts below the nav.push they don’t show. Why is this like every thing works par this.navCtrl.push(‘Page’);

return this.facebook.login(['email'])
      .then( response => {
        const facebookCredential = firebase.auth.FacebookAuthProvider
          .credential(response.authResponse.accessToken);

        firebase.auth().signInWithCredential(facebookCredential)
          .then( success => {
            console.log("Firebase success: " + JSON.stringify(success));
            firebase
              .database()
              .ref(`/userProfile/${success.uid}/email`)
              .set(success.email);
            console.log("Firebase success: " + JSON.stringify(success));
            firebase.auth().onAuthStateChanged(user => {
            if (user) {
              alert("his")
              firebase.database().ref(`/userProfile/${user.uid}/userType`).once("value").then(function (snapshot) {
                alert(snapshot.val())
              if (snapshot.val()!= null){
                
                alert("error1")
                 this.navCtrl.push('Page');
              }
              else{
                alert("error2")
                 this.navCtrl.push('Page2');
               
              }})}})```
#2

Hi, @lunneyd
Here you want to redirect to the page, is that page exists in your app and if “Page” named page exists then you need to write like this:

this.navCtrl.push('PagePage');
this.navCtrl.push('Page2Page');

Hope it helps.

#3

Hi I do have that. If I have alerts after this.navCtrl.push(‘MenuPage’); they don’t show but before they do so it is going into if statement just not navigating to page. If I have this.navCtrl.push(‘MenuPage’); outside if and else it works. Why is this.

`this.navCtrl.push('MenuPage');
` this.navCtrl.push('Menu2Page');``