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

Darshan Hiranandani : How Can I Select a Specific Tab Programmatically in Ionic?

$
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 but 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’)

Regards
Darshan Hiranandani

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49246

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>