How to get the index of the active tab?

Hi, I have tabs inside a modal with this code:

<ion-tabs class="tabs-positive tabs-top">

<ion-tab title="FIND">
<ion-view>
<ion-content>
<div class="list list-inset">
  <label class="item item-input">
    <i class="icon ion-search placeholder-icon"></i>
    <input type="text" ng-model="data.sight" placeholder="Find events or people" ng-change="searchSight()">
  </label>
</div>
</ion-content>
</ion-view>
</ion-tab>
<ion-tab>
   ... More tabs
</ion-tab>
</ion-tabs>

And I have a footer button that I want to perform a particular action according to the active tab, How do I get the active tab in Ionic?

Thank you very much!

You can use $ionicTabsDelegate.selectedIndex() to get the index of the current active tab, further info here: http://ionicframework.com/docs/api/service/$ionicTabsDelegate/

1 Like