Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tab hidden/shown event should give index of tab hidden/shown #634

Closed
gregaton opened this issue Feb 19, 2014 · 2 comments
Closed

tab hidden/shown event should give index of tab hidden/shown #634

gregaton opened this issue Feb 19, 2014 · 2 comments
Milestone

Comments

@gregaton
Copy link

I'm currently using one controller to handle all my tabs (they are dynamically generated). In this case it would be very helpful to know which tab got selected when the shown/hidden event is fired.
For me the index would be fine.

All that's needed as far as I can tell is that the code for the tab directive after $scope.$watch('isVisible', function(value) { is changed from

$rootScope.$broadcast('tab.hidden');
...
$rootScope.$broadcast('tab.shown');

to

$rootScope.$broadcast('tab.hidden', $scope.$index);
...
$rootScope.$broadcast('tab.shown', $scope.$index);
@adamdbradley adamdbradley added this to the 0.9.26 milestone Feb 19, 2014
@ajoslin ajoslin added the tabs label Feb 21, 2014
ajoslin added a commit to ajoslin/ionic that referenced this issue Feb 24, 2014
ajoslin added a commit to ajoslin/ionic that referenced this issue Feb 25, 2014
@ajoslin
Copy link
Contributor

ajoslin commented Feb 25, 2014

These events are broadcasted only to child scopes of a tab, not from $rootScope. That was a bug.

If you wish to detect (in nightly or 0.9.26), do this:

<ion-tabs ng-controller="MyCtrl">
  ...
</ion-tabs>
function MyCtrl($scope) {
  $scope.$watch('tabsController.selectedTab', function(tab) {
    var index = $scope.tabsController.getTabIndex(tab);
    //dosomething
  });
}

<ion-tab> also has on-select and on-deselect expression bindings for you to use.

Documentation is a very high priority and will be coming soon!

@ajoslin ajoslin closed this as completed Feb 25, 2014
ajoslin added a commit that referenced this issue Feb 25, 2014
Closes #597. Fixes #634. Fixes #334. Fixes #175. Fixes #646. Closes #647.
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 6, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants