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

Ionic 4 tab select with button push

$
0
0

@BrentAshWilliams wrote:

Hello,

I have a page with tabs. I have a button on the first tab that when pushed I would like to route/select another tab.

The high level html has the following:

<ion-tabs #my_profile_tabs>
    <ion-tab-bar slot="bottom" color="dark" >
        <ion-tab-button tab="tab1">
            <ion-label>Tab 1</ion-label>
        </ion-tab-button>
        <ion-tab-button tab="tab2">
            <ion-label>Tab 2</ion-label>
        </ion-tab-button>
        <ion-tab-button tab="tab3">
            <ion-label>Tab 3</ion-label>
        </ion-tab-button>
        <ion-tab-button tab="tab4">
            <ion-label>Tab 4</ion-label>
        </ion-tab-button>
    </ion-tab-bar>
</ion-tabs>

In tab 1’s component I have the following:

@ViewChild(‘my_profile_tabs’) tabRef: IonTabs;

On a button click event on the tab 1 I try the following:

this.tabRef.select('tab4');

When the click event occurs tabRef is undefined:

ERROR TypeError: Cannot read property 'select' of undefined

Any thoughts on what I am doing wrong?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49300

Trending Articles



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