Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49312

How can I programmatically select specific Ionic tab?

$
0
0

How can I programmatically select specific Ionic tab (in typescript file)? For example if I have in template…

  • I’m using Ionic 8 and Angular 18
<ion-tabs>
  <ion-tab-bar slot="bottom" >
    <ion-tab-button tab="home">
      <ion-icon name="home"></ion-icon> Home
    </ion-tab-button>

    <ion-tab-button tab="favorites">
      <ion-icon name="heart"></ion-icon> Favorites
    </ion-tab-button>
  </ion-tab-bar>
</ion-tabs>

How can I programmatically select home tab?

I have tried with @ViewChild buth without success:

@ViewChild('tabs', {static: true}) tabs:IonTabs | undefined;

and than

this.tabs?.select('home')

but it is not working. The error I get is…

TypeError: Cannot read properties of undefined (reading ‘getActiveStackId’)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49312

Trending Articles