Directing user to an ion-tab using function

Issue

I have an ion-tab which I need to redirect the user to using the click() function in JavaScript. Any ideas please or any references to docs please?
This is my code:

<ion-tab tab="list">
    <ion-header>
        <ion-toolbar>
            <ion-title>This is the header area</ion-title>
        </ion-toolbar>
    </ion-header>

    <ion-content>
        <ion-label>This is the content area</ion-label>
    </ion-content>
</ion-tab>

<ion-tab-bar slot="bottom">
    <ion-tab-button tab="list">
        <ion-label>List</ion-label>
        <ion-icon name="list-outline"></ion-icon>
    </ion-tab-button>
</ion-tab-bar>

function goToListTab()
{
    // How do I direct the user to the Ionic tab named "list" using click()
}

Solution

I used onclick="console.log(this)" in the ion-tab-button to get the id of the button then used document.getElementById().click() in the function to automatically redirect the user to the list tab when the function runs

Answered By – Student

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published