# Open second tab from the side menu

**URL:** <https://forum.ionicframework.com/t/open-second-tab-from-the-side-menu/95046>\
**Category:** ionic-v3\
**Created:** [June 20, 2017, 3:23am UTC](https://forum.ionicframework.com/t/open-second-tab-from-the-side-menu/95046 "2017-06-20T03:23:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vcarvalho0402](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vcarvalho0402/32/110697_2.png) [@vcarvalho0402](https://forum.ionicframework.com/u/vcarvalho0402)\
**Post date:** [June 20, 2017, 3:23am UTC](https://forum.ionicframework.com/t/open-second-tab-from-the-side-menu/95046/1 "2017-06-20T03:23:27Z")

</div>

There are two tabs in my app. On the `<ion-menu>` there are links for both tabs. When I click on the `Tab1` button the first tab is open and it’s OK.  
But when I click on the `Tab2` I need to show the tab2Page on the tabsPage, but if I try:

```auto
this.nav.setRoot(tabs2Page)

```

The page is shown without tabs.

How can I go to the second tab from the side menu?

`app.html`:

```auto
<ion-menu [content]="nav">
  <ion-header>
    <ion-toolbar>
      <ion-title>Menu</ion-title>
    </ion-toolbar>
  </ion-header>
  <ion-content>
    <ion-list>
      <button ion-item (click)="onLoad(tabsPage)">
        <ion-icon name="book" item-left></ion-icon>
        Tab1
      </button>
      <button ion-item (click)="onLoad(tab2)">
        <ion-icon name="list-box" item-left></ion-icon>
        Tab2
      </button>
      <button ion-item (click)="onLoad(settingsPage)">
        <ion-icon name="settings" item-left></ion-icon>
        Configurações
      </button>
    </ion-list>
  </ion-content>
</ion-menu>

```

`app.component.ts`:

```auto
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  tabsPage = TabsPage;
  tab2 = Tab2Page;
  settingsPage = SettingsPage;

  //...

 onLoad(page: any) {
    this.nav.setRoot(page);
    this.menuCtrl.close();
  }
}

```

`tabs.html`

```auto
<ion-tabs tabsPlacement="top" #appTabs>
  <ion-tab [root]="tab1page" tabIcon="book"></ion-tab>
  <ion-tab [root]="tab2Page" tabIcon="list-box"></ion-tab>
</ion-tabs>

```

---

<div class="post-metadata">

**Author:** ![vnyksj](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@vnyksj](https://forum.ionicframework.com/u/vnyksj)\
**Post date:** [June 20, 2017, 6:30am UTC](https://forum.ionicframework.com/t/open-second-tab-from-the-side-menu/95046/2 "2017-06-20T06:30:46Z")

</div>

Hi @vcarvalho0402,  
Instead Of setRoot() try Select Option of Tabs, i.e  
`this.navCtrl.parent.select(TabIndex);`  
where TabIndex is an Index of a tab that you want to be selected, For ex, If you have 2 tabs like Tab1, Tab2 and if you want to select Tab2 from your side menu then you can write something like this,  
`this.navCtrl.parent.select(1);`

---

<div class="post-metadata">

**Author:** ![vcarvalho0402](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vcarvalho0402/32/110697_2.png) [@vcarvalho0402](https://forum.ionicframework.com/u/vcarvalho0402)\
**Post date:** [June 20, 2017, 12:06pm UTC](https://forum.ionicframework.com/t/open-second-tab-from-the-side-menu/95046/3 "2017-06-20T12:06:17Z")

</div>

Thanks @vnkyksj,  
when going through the link on the menu the parent at `this.navCtrl.parent` is null.

But with your answer I got it working using navParams:

On the click envent of my menu I send the tabIndex:  
`this.nav.setRoot(this.tabsPage, {tabIndex: 1});`

On the tabsPage:

```auto
  ...
  public tabIndex: Number = 0;

  constructor(public params: NavParams) {
    let tabIndex = this.params.get('tabIndex');
    if (tabIndex) {
      this.tabIndex = tabIndex;
    }
  }

```

And my tabs.html:

```auto
<ion-tabs [selectedIndex]='tabIndex' tabsPlacement="top" #tabs>
  <ion-tab [root]="tab1Page" tabIcon="book"></ion-tab>
  <ion-tab [root]="tab2Page" tabIcon="list-box"></ion-tab>
</ion-tabs>

```

Thank you for your help
