ionic-framework - how to navigate to specific tabs index from other page(dont have tab originally) in ionic 3?
问题描述
I have a page name EatPage that doesn't have any tabs on it. What I want to do is to navigate from MyPage to tab bar index 2 and pass parameter from EatPage.
I have tried using this code to pass parameter
opentab2(id: string) {
this.navCtrl.push('TabsPage', {
docId: id
});
but don't know how to change tab from here.
解决方案
If you are talking about Ionic Tabs, then syntax is like this.
TabsPage
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
fooId:any;
constructor() {
this.fooId = "some-value";
// this tells the tabs component which Pages should be each tab's root Page
this.tab1Root = Tab1;
this.tab2Root = Tab2;
this.tab3Root = Tab3;
}
}
Page
<ion-tabs>
<ion-tab tabTitle="Tab1" [root]="tab1Root" [rootParams]="fooId"></ion-tab>
<ion-tab tabTitle="Tab2" [root]="tab2Root" [rootParams]="fooId"></ion-tab>
<ion-tab tabTitle="Tab3" [root]="tab3Root" [rootParams]="fooId"></ion-tab>
</ion-tabs>
else if you want to pass values i would suggest to use services. Tell me if you want to know how its done via services.ill share the code here.
Read more here and official docs
推荐阅读
- javascript - 在 Javascript 中使用变量在调用查询的 cfml 标记中添加功能
- sql-server - SSIS 2014 - 列镜像
- javascript - express-validator - req.checkBody 不是函数
- php - 每个 jquery 访问值
- php - 使用 php/codeigntier 按月组织 MySQL 数据
- sql - How to show the final count in each row returned?
- java - 具有 UserDetailsService 实现的 Spring Security
- c# - c#更快的设置像素颜色的方法
- javascript - Javascript如何旋转一系列唯一ID中的图像?
- vba - 与帐户有权访问的组关联的唯一主机计数