How to select a tab with Ionic5?

Hi,
which is the correct way to select programmatically a tab with Ionic5?

With previous versions of Ionic I used the code:
his.navCtrl.parent.select(tabIndex);

The tabs are defined in this way:

<ion-tabs>

  <ion-tab-bar slot="bottom">
    <ion-tab-button tab="dashboard">
      <ion-icon name="triangle"></ion-icon>
      <ion-label>Tab 1</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="tab2">
      <ion-icon name="ellipse"></ion-icon>
      <ion-label>Tab 2</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="tab3">
      <ion-icon name="square"></ion-icon>
      <ion-label>Tab 3</ion-label>
    </ion-tab-button>
  </ion-tab-bar>

</ion-tabs>

Thank you

Claudio B.

Excuse me, I’ve solved in this way:
this.router.navigateByUrl('tabs/dashboard');

Ref: Ionic v4: Change active tab dynamically

2 Likes