0
私はエラーfirebase.authは()AngularFire
キャッチされない(約束で)を取得するためのいかなるプロバイダをonAuthStateChangedません!私はfirebase.auth().onAuthStateChanged
を呼び出そうとしました
。 これがなぜ発生するのかわかりません。助けてください。
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
import { Login } from '../pages/login/login';
import firebase from 'firebase';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = Login;
isAuthenticated = false;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
firebase.initializeApp({
apiKey: "AIzaSyC94rD8wXG0aRLTcG29qVGw8CFfvCK7XVQ",
authDomain: "myfirstfirebaseproject-6da6c.firebaseapp.com",
});
firebase.auth().onAuthStateChanged(user => {
if (user) {
this.isAuthenticated = true;
this.rootPage = HomePage;
} else {
this.isAuthenticated = false;
this.rootPage = Login;
}
});
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();
});
}
}
app.module.tsを追加できますか? –
アプリモジュールで何を追加する必要がありますか? – Jason
あなたのプロジェクトには、app.module.tsに注入されたアングラファイアが含まれていますか? @surajが上で尋ねるように、このファイルの内容を貼り付けることができます –