Created
December 19, 2016 17:03
-
-
Save MT--/0bee9e4268c279bb027787f75091a4dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { Platform } from 'ionic-angular'; | |
import { SessionService } from '../providers/session.service'; | |
@Component({ | |
template: `<ion-nav [root]="rootPage"></ion-nav>` | |
}) | |
export class MyApp { | |
public rootPage: any; | |
constructor( | |
public platform: Platform, | |
public sessionSvc: SessionService | |
) { | |
// Cordova is available | |
platform.ready().then(() => { | |
// observe login state and route accordingly | |
this.sessionSvc.isLoggedIn.subscribe(isLoggedIn => { | |
if ( isLoggedIn ) { | |
this.rootPage = TabsPage; | |
} else { | |
this.rootPage = LoginPage; | |
} // end if | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment