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 { AuthService } from './../providers/auth.service' ; import { HomePage } from './../pages/home/home' ; import { SigninPage } from './../pages/signin/signin' ; import { User } from './../models/user.model' ; import { UserService } from './../providers/user.service' ; import * as firebase from 'firebase/app' ; @ Component ( { templateUrl : 'app.html' } ) export class MyApp { rootPage : any ; currentUser : User ; constructor ( authService , platform , statusBar , splashScreen , userService ) { authService . afAuth . authState . subscribe ( ( authUser ) => { if ( authUser ) { this . rootPage = HomePage ; userService . currentUser . valueChanges ( ) . subscribe ( ( user ) => { this . currentUser = user ; } ) ; } else { this . rootPage = SigninPage ; } } ) ; platform . ready ( ) . then ( ( ) => { statusBar . styleDefault ( ) ; splashScreen . hide ( ) ; } ) ; } }