Reputation: 391
On my login page I am using this.nav.setRoot(TabsPage);
to navigate to the 'main app'. However, this makes the first tab the default page. On the other hand, if i use this.nav.setRoot(HomePage)
; I get the correct page but am missing the tabs. How do I set the default tab on page switch?
Upvotes: 5
Views: 6379
Reputation: 391
After further googling, I found the solution in the ionic2 documents. If anyone else in the future is wondering the same thing, the solution is to add selectedIndex="X"
to the <ion-tabs>
tag. (http://ionicframework.com/docs/v2/api/components/tabs/Tabs/)
UPDATE for clarity: your code will look like this for selecting the 3rd tab:
<ion-tabs selectedIndex="2">
and like this fore selecting the 2nd tab:
<ion-tabs selectedIndex="1">
Upvotes: 20