Skip to content

Instantly share code, notes, and snippets.

@MT--
Created December 19, 2016 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MT--/0bee9e4268c279bb027787f75091a4dd to your computer and use it in GitHub Desktop.
Save MT--/0bee9e4268c279bb027787f75091a4dd to your computer and use it in GitHub Desktop.
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