# Set the active tab in Ionic 4

**URL:** <https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981>\
**Category:** Ionic Framework\
**Created:** [November 19, 2018, 7:46pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981 "2018-11-19T19:46:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliverandersen](https://avatars.discourse-cdn.com/v4/letter/o/a4c791/32.png) [@oliverandersen](https://forum.ionicframework.com/u/oliverandersen)\
**Post date:** [November 19, 2018, 7:46pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/1 "2018-11-19T19:46:32Z")

</div>

I want to change the tab from certain pages in the app.

Using:

private app: App does not work in Ionic 4

I also created a local ref on the ion-tabs element and tried setting it using the ‘select()’ method - but i get this error:

`TypeError: e.setActive is not a function`

How can I select the tab programatically in Ionic 4  
?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [November 19, 2018, 9:01pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/2 "2018-11-19T21:01:10Z")

</div>

Feel free to completely ignore my opinion, but I think that it is part of a framework’s job to steer developers towards good UX choices, and this is a situation where what you are trying to do _should_ be hard, if not impossible.

The natal metaphor for tabs comes from filing cabinets, where one could (for example) switch amongst “customers”, “billing”, and “orders”: all completely separate and independent groups of information. Tabs allow them to share screen real estate, by having only one be active at a time.

What goes on in each tab needs to be confined to activities in that tab: if I leave tab A to go to tab B and then come back to tab A, it should be just as I left it.

The decision to switch tabs should be at the sole discretion of the user. Sometimes there are circumstances under which some tabs might not be available: disable them instead of removing them from the DOM, and never “warp” the user magically from one tab to another.

To summarize, if I found myself in your position, my first thought would be “programatically shifting UI focus is generally a disorienting user experience. Am I _absolutely_ sure I want to do that?” And if I’m still convinced that it is, then I would look for a different way to present the UI than tabs, because users would expect tabs to work in a certain way, and I’m not going to uphold that expectation.

---

<div class="post-metadata">

**Author:** ![oliverandersen](https://avatars.discourse-cdn.com/v4/letter/o/a4c791/32.png) [@oliverandersen](https://forum.ionicframework.com/u/oliverandersen)\
**Post date:** [November 24, 2018, 7:28pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/3 "2018-11-24T19:28:38Z")

</div>

Agreed the separation is better towards UX, however I am interested in knowing just how one would go about switching from tab to tab.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [June 3, 2019, 1:38pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/4 "2019-06-03T13:38:46Z")

</div>

So there’s to ways to do this in the latest Ionic

1. Using the `select` method of the ion-tabs component

> **[Ionic Documentation](https://ionicframework.com/docs/api/tabs#methods)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

1. Calling the Angular Router APIs and just making that switch based on URLs

---

<div class="post-metadata">

**Author:** ![SharanA](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@SharanA](https://forum.ionicframework.com/u/SharanA)\
**Post date:** [June 3, 2019, 3:45pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/5 "2019-06-03T15:45:39Z")

</div>

@mhartington Thank you so much for quick response. Its working.

@ViewChild(‘app\_tabs’) tabRef: IonTabs;  
this.tabRef.select(“tabName”);

---

<div class="post-metadata">

**Author:** ![eaxidev](https://avatars.discourse-cdn.com/v4/letter/e/5daacb/32.png) [@eaxidev](https://forum.ionicframework.com/u/eaxidev)\
**Post date:** [June 13, 2019, 10:15pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/6 "2019-06-13T22:15:06Z")

</div>

> [@SharanA](#):
>
> app\_tabs

hello @SharanA may i ask on how does it works because i tried it but it show an error select is undefined thanks, im stuck in here.

---

<div class="post-metadata">

**Author:** ![karthikmani15](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@karthikmani15](https://forum.ionicframework.com/u/karthikmani15)\
**Post date:** [July 4, 2019, 12:37pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/7 "2019-07-04T12:37:29Z")

</div>

It Cannot Work.What Will Do friend

---

<div class="post-metadata">

**Author:** ![hanho](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hanho](https://forum.ionicframework.com/u/hanho)\
**Post date:** [November 7, 2020, 10:24am UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/8 "2020-11-07T10:24:16Z")

</div>

Please check .select method calls after ngAfterViewInit.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 8:52pm UTC](https://forum.ionicframework.com/t/set-the-active-tab-in-ionic-4/147981/9 "2021-07-19T20:52:34Z")

</div>

Closed on July 19, 2021, 8:52pm UTC


