When i serve showing an error please check my error screen shot
Please provide information of how your LoginPage looks like.
app.component.ts
import { LoginPage } from './../pages/login/login';
import { Component,ViewChild } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Nav } from 'ionic-angular/components/nav/nav';
import { MenuComponent } from '../pages/menu/menu';
import { AngularFireAuth } from 'angularfire2/auth';
@Component({
template: '<ion-nav #baseNav></ion-nav>',
})
export class MyApp {
@ViewChild('baseNav') nav: Nav;
ngOnInit() {
const componentStack: Array<{ page: Component }> = [{
page: MenuComponent
}];
this.afAuth.authState.subscribe(data => {
if (!(data && data.uid)) {
componentStack.push({ page: LoginPage });
}
this.nav.insertPages(0, componentStack, { animate: false });
})
// if (!this.loginService.isLoggedIn)
// {
//componentStack.push({ page: LoginPage });
// }
}
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,private afAuth: AngularFireAuth) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
}
login.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController } from 'ionic-angular';
import { User } from "../../models/user";
import { AngularFireAuth } from 'angularfire2/auth';
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage {
user = {} as User;
constructor(private afAuth: AngularFireAuth,
public navCtrl: NavController, public navParams: NavParams, private toastCtrl: ToastController) {
}
async login(user: User) {
try {
const result = this.afAuth.auth.signInWithEmailAndPassword(user.email, user.password);
result.then(auth => {
this.navCtrl.pop();
}).catch(e => {
let toast = this.toastCtrl.create({
message: e.message,
duration: 1000
});
toast.present();
})
// if (result) {
// this.navCtrl.setRoot('HomePage');
// }
}
catch (e) {
//console.error(e);
let toast = this.toastCtrl.create({
message: e.message,
duration: 10000
});
toast.present();
}
}
register() {
this.navCtrl.push('RegisterPage');
}
}
how can i fix that?
Hi you got the solution of this issue i am getting same issue. please help if you got the solution.