Hi,
I want to execute a method when a user clicks on the active ion-tab.
I tried (ionChange)="myFunction()" in the ion-tabs parent element, but that only fires when the tab changes. I want to capture the event even when the tab doesn’t change (final goal is to make the current tab reload itself / scroll up).
Hi @mhartington, thank you for your reply. I have tried exactly what you posted before as well.
The issue with that solution is that (ionSelect) only fires when the selection changes.
Because the selection does not change when you select an already active tab, it does not fire. Therefore I can’t use it for my purposes. I need something that fires even when it selects the same tab that you are on.
No, I did not find any way to solve it. I still have the issue.
I also did not get any further response from @mhartington or the Ionic Team about this issue, a bit sad really looks like this is currently not possible.
This doesn’t seem to work for me (in RC2). When the tab A is being viewed and tab B is selected then ionSelect fires. When tab B is viewed and tab B is selected then ionSelect does not fire.
The goal is to be able to detect tab B was selected when tab B contents were being viewed, this is to allow some refresh/view reset/scroll to top to occur
I’d like to solve for the same feature as @danielabbatt - it is, for many heavy mobile users, a known action when you click on an already active tab you will scroll to the top of that tab page, so you don’t have to manually scroll all the way back up if you’ve been going through a number of search results, or something similar. Any response/solution for this yet?
To resolve this issue, you need to modify from the source code for now
inside the ionic project at node_modules\ionic-angular\components\tabs\tabs.js (or tabs.ts)
In different rc build, the source code of tabs.js(or tabs.ts) might be different.
Basically, the guideline is in the select tab function
Tabs.prototype.select = function (tabOrIndex, opts)
if (selectedTab.root) //this is the active tab
you will still need to file the event and the code is
this.ionChange.emit(selectedTab);
Hope it is helpful for the people who is looking for the solution.
This is very inconvenience that can’t select the active tab for some scenarios.