导航后消失的标签(侧面菜单+标签)

时间:2017-11-21 19:47:20

标签: ionic-framework ionic3

我有一个使用侧边菜单和基于Ionic Conference App的标签的应用。应用程序在开始时按预期工作,并且显示选项卡和侧面菜单,但是当您转到非选项卡页面然后通过侧面菜单返回选项卡页面时,选项卡将消失。这是我的相关代码。任何人都有任何想法,为什么这可能没有按预期工作? :X

export class MyApp {


 // Reference to the app's root nav
@ViewChild(Nav) nav: Nav;

rootPage: any;


 pages: PageInterface[] = [
{ title: 'Applications', pageName: 'HomePage',  index: 0, icon: 'home' },
{ title: 'New Entries ', pageName: 'JobEntryPage',  index: 1, icon: 'map' },

{ title: 'Statistics', pageName: 'StatisticsPage', index: 2, icon: 'stats'},

];

socialPages: PageInterface[] = [

{ title: 'Company List', pageName: 'CompaniesPage', component: 
'CompaniesPage', icon: 'log-out'}

];

accountPages: PageInterface[] = [
{ title: 'Profile', pageName: 'ProfilePage', component: 'ProfilePage', icon: 
'person' },

{ title: 'Logout', pageName: 'LogoutPage', component: 'LogoutPage', icon: 
'log-out'}   
];

 constructor(public platform: Platform, public statusBar: StatusBar, public 
splashScreen: SplashScreen,
            private afAuth: AngularFireAuth, public fb: FirebaseProvider,
          public menu: MenuController) {

this.initializeApp();

this.afAuth.authState.subscribe(auth => {
  if(!auth)
    this.rootPage = 'LoginPage';
  else
    this.rootPage = 'TabsPage';
 });


}

initializeApp() {
this.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.
  this.statusBar.styleDefault();
  this.splashScreen.hide();
 });
}


openPage(page: PageInterface) {
let params = {};

    // the nav component was found using @ViewChild(Nav)
    // setRoot on the nav to remove previous pages and only have this page
    // we wouldn't want the back button to show in this scenario
    if (page.index) {
      params = { tabIndex: page.index };
    }

    // If we are already on tabs just change the selected tab
    // don't setRoot again, this maintains the history stack of the
    // tabs even if changing them from the menu
    if (this.nav.getActiveChildNavs().length && page.index != undefined) {
      this.nav.getActiveChildNavs()[0].select(page.index);
      // Set the root of the nav with params if it's a tab index
    } else {
      console.log(page.pageName)
      this.nav.setRoot(page.pageName, params).catch((err: any) => {
        console.log(`Didn't set nav root: ${err}`);
      });
 }
}

0 个答案:

没有答案