I have a dynamic tabs page in my Ionic2 app that looks like this:
<ion-tabs #myTabs class="tabs-md" type="md" [tabsHighlight]="true" [selectedIndex]="mySelectedIndex">
<ion-tab *ngFor="let tab of tabRoots" [root]="tab.page" [tabTitle]="tab.name" [tabIcon]="tab.icon"></ion-tab>
</ion-tabs>
When the user taps on a tab that is already selected and is therefore the root page already, the page will still reload. The issue is that I have a few custom animations that rerun when this happens. So I want to disable the ability to navigate to your same root page.
I've tried putting
ionViewCanLeave() {
return //viewchild of #myTabs and returns true if next page does not equal current page.
}
This worked in that it stopped the refresh of the current root page, but the app crashes when navigating to another page that isnt a root (a child page) because myTabs reference is undefined.
Any advice on how to accomplish this? I would prefer to handle this from my tabs controller.