# Selecting a different tab programmatically

**URL:** <https://forum.ionicframework.com/t/selecting-a-different-tab-programmatically/160660>\
**Category:** ionic-v3\
**Created:** [April 3, 2019, 7:03am UTC](https://forum.ionicframework.com/t/selecting-a-different-tab-programmatically/160660 "2019-04-03T07:03:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![obinnae](https://avatars.discourse-cdn.com/v4/letter/o/a183cd/32.png) [@obinnae](https://forum.ionicframework.com/u/obinnae)\
**Post date:** [April 3, 2019, 7:03am UTC](https://forum.ionicframework.com/t/selecting-a-different-tab-programmatically/160660/1 "2019-04-03T07:03:41Z")

</div>

My app has 3 tabs. In tab 0, there’s a button, which when pressed, calls the following function

`this.navCtrl.push('NewRequestPage');`

which redirects to a page with a request form. The tabs aren’t visible here.  
After submitting the form, it redirects to (or at least is supposed to go straight to) tab 1 via this code

`this.navCtrl.setRoot('TabsHome',{tab:1});`

Here’s some of the code in the TabsHome page:

```auto

@IonicPage()
@Component({
selector: 'page-tabs-home',

//templateUrl: 'tabs-home.html'

template: `
<ion-tabs [selectedIndex]="selectedTab" (ionChange)="tabChanged($event)" color="dark" #myTabs id="tabs">
<ion-tab tabTitle="Home" [root]="home_tab" tabIcon="home"</ion-tab>
<ion-tab tabTitle="Active" [root]="active_tab" tabIcon="star"</ion-tab>
<ion-tab tabTitle="Submitted" [root]="submitted_tab" tabIcon="checkmark"</ion-tab>
</ion-tabs>'
})

export class TabsHome {

@ViewChild('myTabs') tabRef: Tabs;
//.... other stuff

if (this.params.get("tab"))
    { 
      this.selectedTab=parseInt(this.params.get("tab"));
      this.tabRef.select(this.params.get("tab"),{},false);
    }
    else
      this.selectedTab = 0;

```

As it is now, instead of going straight to tab 1, it goes to tab 0, then 1, albeit rapidly.

How can I force it to go straight to tab 1, instead of showing 0 before 1?

Do you recommend the form page be opened as a modal, instead of navctrl.push?

---

<div class="post-metadata">

**Author:** ![obinnae](https://avatars.discourse-cdn.com/v4/letter/o/a183cd/32.png) [@obinnae](https://forum.ionicframework.com/u/obinnae)\
**Post date:** [April 3, 2019, 9:30pm UTC](https://forum.ionicframework.com/t/selecting-a-different-tab-programmatically/160660/2 "2019-04-03T21:30:00Z")

</div>

Any help would be greatly appreciated?  
Basically what I’m trying to do is to highlight the correct tab from within the tabs page. When the selectedTab variable is set, the correct page shows, but the original tab is still highlighted. What’s the code for highlighting the correct tab from within tabsPage.ts?

Thanks.
