I have a LandingPage before loading TabsPage.
The user can click a button on LandingPage to trigger this.navCtrl.setRoot(TabsPage)
The problem is right after the TabsPage is loaded, there is a back button on the navbar of the default tab page.
Clicking the back button will pop the default page, while another default page will be seen.
As I remember, this happens since RC0.
It seems I couldn’t find similar posts here…
Does anyone have similar issues?
Hi, glad to hear I’m not the only one having this problem lol.
So hopefully they will fix it or provide a correct way to implement if it was due to improper implementation, because my workaround is really just a quick hack…
What I did is to tell the default active tab to remove once its nav stack when TabsPage is loaded at the first time.
We need to use ViewChild to reference the tabs component on TabsPage
<ion-tabs #tabs>
Add this to TabsPage:
@ViewChild('tabs') tabs;
Because ionViewDidEnter will be called whenever it became active, we need a flag to ensure it will only be called at the first time. By the way, I was testing and found out in some cases this won’t happen…so I check if there are really more than one page. Add this to TabsPage:
i’ve put this.firstLoaded = true; outside of the if and added a console.log in ionViewDidEnter()
this is the order they get executed:
[Log] Hello Home Page (main.js, line 31640)
[Log] Hello Tabs Page (main.js, line 31692)
[Log] Hello Home Page (main.js, line 31640)
[Log] TabsPage.ionViewDidEnter() (main.js, line 31695)
I’m having the same problem…
While the solution presented works, it looks buggy. I mean, when the app loads I can see that a page is being loaded and then destroyed.
I was trying to solve another problem after upgrading to RC4…
Then I realized the rendering issue happened only on all the tabs at the first level.
So I tried using NgZone to run setRoot(TabsPage)
And some how it solves both the problems…
Using Zone.run is virtually always papering over a more serious problem. I strongly urge people not to be satisfied with it and instead search for the root cause of their underlying issue.
Trying to implement this in my project but I never setRoot() for the tabs pages, as I use a tabs view inside of my side menu app. Essentially I click a link to navigate to a page that has the tabs views…everything works great other than the double loading when selecting the tabs, not just the default page but all tabs load twice only on first selection…
Thanks, this solve a problem to me… After show another page and go to the tabs tabe i lose the selected page (the tab selection), the links was working but i lose the selected tab in the top
I had some issues with the getSelected() workaround, but I found another simple workaround for those whose problem persists. I just created a tabCounter in a provider which is incremented by the Tabs_Page, when the counter is equal to 2, you can call your funtion: myProvider.ts
@Injectable()
export class MyProvider {
public tabCounter: number = 0;
}