import {Component,ViewChild} from '@angular/core';
import {Platform, ionicBootstrap, Storage, SqlStorage,Nav,NavController,MenuController} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {LoginPage} from './pages/login/login';
import {SearchPage} from './pages/search/search';
@Component({
templateUrl: 'build/app.html',
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any;
pages: any;
private navCtrl:NavController;
constructor(platform: Platform, menu: MenuController) {
// set our app's pages
this.pages = [
{ title: 'Buscar Médicos', component: SearchPage, params: {} },
{ title: 'Sair', component: LoginPage, params: { logout: true } }
];
//Instance
let storage = new Storage(SqlStorage);
menu.swipeEnable(false);
//Create Database
storage.query("Create table if not exists paciente (idpaciente integer, idplano integer)");
storage.query("select * from paciente").then(
data=>{
if(data.res.rows.length > 0){
this.rootPage = SearchPage;
}else{
this.rootPage = LoginPage;
}
},
error=>{
this.rootPage = LoginPage;
}
);
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();
StatusBar.hide();
});
}
openPage(page) {
//let nav = this.app.getComponent('nav');
//console.log(this.nav);
this.nav.rootNav.setRoot(page.component,page.params);
}
}//Class
ionicBootstrap(MyApp, [],{
backButtonText: 'Voltar',
});
TypeScript error: app/app.ts(59,5): Error TS2341: Property ‘rootNav’ is private and only accessible within class ‘NavControllerBase’.
I get this error after I update to beta 11