import { Component , ViewChild } from '@angular/core' ; import { Nav , Platform } from 'ionic-angular' ; import { StatusBar } from '@ionic-native/status-bar' ; import { SplashScreen } from '@ionic-native/splash-screen' ; import { AuthService } from '../services/auth.service' ; @ Component ( { templateUrl : 'app.html' } ) export class MyApp { @ ViewChild ( Nav ) nav : Nav ; rootPage : string = 'HomePage' ; pages : Array < { title : string ; component : string ; } > ; constructor ( public platform , public statusBar , public splashScreen , public auth ) { this . initializeApp ( ) ; this . pages = [ { title : 'Profile' , component : 'ProfilePage' } , { title : 'Categorias' , component : 'CategoriasPage' } , { title : 'Carrinho' , component : 'CartPage' } , { title : 'Logout' , component : '' } ] ; } initializeApp ( ) { this . platform . ready ( ) . then ( ( ) => { this . statusBar . styleDefault ( ) ; this . splashScreen . hide ( ) ; } ) ; } openPage ( page ) { switch ( page . title ) { case 'Logout' : this . auth . logout ( ) ; this . nav . setRoot ( 'HomePage' ) ; break ; default : this . nav . setRoot ( page . component ) ; } } }