Intercept tab click and cancel the action?

Hi, I’m looking to have some logic run when the user clicks on a particular tab and based on that maybe not switch them to the new tab.

I’ve found this thread: Can I bind an action to a tab bar button? but the bindings are on tab.shown which is too late to cancel the navigation.

Is anyone aware of a simple way to intercept that action and possibly cancel it? We’re using the standard ion-tabs and ion-tab elements to build them.

Thanks

1 Like

http://www.clearlyinnovative.com/blog/post/34758525881/ionic-framework-tabs-go-home-view

here is intercept the behavior when the tab is selected and change the state, I think this might be a good start for what you are trying to accomplish

2 Likes

Thanks Aaron, you got me on the right track. While I was looking at the on-select stuff you are using I found the ng-click for ion-tab does what I need:

By default, the tab will be selected on click. If ngClick is set, it will not. You can explicitly switch tabs using $ionicTabsDelegate.select().

So I can use the ng-click to invoke my logic and manually switch the tab if I need.

glad i could help out