Tab.hidden not fired


#1

Hi,

Refer to codepen ‘Ionic Sign-in, then Tabs’ example http://codepen.io/ionic/pen/kcjLb ,
the tab.hidden event is not fired if I add the following code in HomeTabCtrl.

.controller(‘HomeTabCtrl’, function($scope) {
console.log(‘HomeTabCtrl’);

$scope.$on(‘tab.shown’, function() {
// Maybe load some content here
console.log(‘Home tab.shown’);
});
$scope.$on(‘tab.hidden’, function() {
// Perhaps cycle out some data in memory here
console.log(‘Home tab.hidden’);
});
});


Set active state of a tab
#2

Actually, it does fire. However, it only fires one time. Thanks for pointing this out!

Sample : http://codepen.io/calendee/pen/blmDg

I’ve opened Issue # 813 : https://github.com/driftyco/ionic/issues/813


#3

So those events were actually removed in all future versions. You might want to see the alternative options here:


#4

I have tried $scope.on(’$destroy’), and it works well.

What is the alternative option for ‘tab.shown’?


#5

“Instead, use on-select and on-deselect attribute callbacks.”

See this sample : http://codepen.io/calendee/pen/kaHGK/