My app has 3 tabs. In tab 0, there’s a button, which when pressed, calls the following function
this.navCtrl.push('NewRequestPage');
which redirects to a page with a request form. The tabs aren’t visible here.
After submitting the form, it redirects to (or at least is supposed to go straight to) tab 1 via this code
this.navCtrl.setRoot('TabsHome',{tab:1});
Here’s some of the code in the TabsHome page:
@IonicPage()
@Component({
selector: 'page-tabs-home',
//templateUrl: 'tabs-home.html'
template: `
<ion-tabs [selectedIndex]="selectedTab" (ionChange)="tabChanged($event)" color="dark" #myTabs id="tabs">
<ion-tab tabTitle="Home" [root]="home_tab" tabIcon="home"</ion-tab>
<ion-tab tabTitle="Active" [root]="active_tab" tabIcon="star"</ion-tab>
<ion-tab tabTitle="Submitted" [root]="submitted_tab" tabIcon="checkmark"</ion-tab>
</ion-tabs>'
})
export class TabsHome {
@ViewChild('myTabs') tabRef: Tabs;
//.... other stuff
if (this.params.get("tab"))
{
this.selectedTab=parseInt(this.params.get("tab"));
this.tabRef.select(this.params.get("tab"),{},false);
}
else
this.selectedTab = 0;
As it is now, instead of going straight to tab 1, it goes to tab 0, then 1, albeit rapidly.
How can I force it to go straight to tab 1, instead of showing 0 before 1?
Do you recommend the form page be opened as a modal, instead of navctrl.push?