在我的应用程序中,我有一个带有项目的侧菜单(主页、联系人、选项卡1、选项卡2(和带有选项卡的选项卡菜单(选项卡1、标签2(。当我从侧菜单单击选项卡1或选项卡2时,选项卡菜单在带有侧菜单的页面上可见,但当我从侧面菜单单击主页或联系人时,选项卡列表消失。我需要所有页面的选项卡菜单和侧菜单。如果我从侧菜单点击主页,标签菜单应该在主页上没有活动标签。
谢谢你的帮助。
选项卡.html
<ion-tabs [selectedIndex]="myIndex">
<ion-tab [root]="tab1Root" tabTitle="Tab 1" tabIcon="HOME"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="Tab 2" tabIcon="BOND"></ion-tab>
</ion-tabs>
表.ts
tab1Root = Tab1Page; tab2Root = Tab2Page;
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.myIndex = navParams.data.tabIndex;
}
菜单.ts
rootPage = TabsPage;
@ViewChild(Nav) nav: Nav;
pages: PageInterface[] = [
{ title: 'Home', component: HomePage },
{ title: 'Contact', component: ContactPage},
{ title: 'Tab 1', component: TabsPage,tabComponent: Tab1Page, index:0 },
{ title: 'Tab 2', component: TabsPage,tabComponent: Tab2Page, index:1 },
];
constructor(public navCtrl: NavController, public navParams: NavParams,
private app:App) {
}
openPage(page: PageInterface) {
let params = {};
// The index is equal to the order of our tabs inside tabs.ts
if (page.index) {
params = { tabIndex: page.index };
}
// If tabs page is already active just change the tab index
if (this.nav.getActiveChildNavs().length && page.index != undefined) {
this.nav.getActiveChildNavs()[0].select(page.index);
} else {
this.nav.setRoot(page.component,params);
}
}
菜单.html
<ion-menu [content]="content">
<ion-header>
<ion-toolbar>
<ion-title text-center class="clss_toogle_mnu"></ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="menu_background">
<ion-list>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
<span>{{p.title}}</span>
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
编辑:在menu.ts中,我在setRoot中添加了params。
在菜单.ts文件中尝试这种方式
pages: PageInterface[] = [
{ title: 'Menu', pageName: 'TabsPage', tabComponent: 'HomePage', index: 0, icon: 'home' },
{ title: 'List', pageName: 'TabsPage', tabComponent: 'ListPage', index: 1, icon: 'contacts' },
{ title: 'Test', pageName: 'TestPage', icon: 'home' }]
并尝试在openPage方法中这样做
if (this.nav.getActiveChildNavs() && page.index != undefined) {
this.nav.getActiveChildNavs().push(page.index);
} else {
this.nav.push(page.pageName);
}
我希望这将有助于