fix(tabs): fire leaving life cycle events

Closes #2869
This commit is contained in:
Adam Bradley
2015-02-16 14:40:23 -06:00
parent 0e04f39105
commit 9cc61ecdce
3 changed files with 108 additions and 0 deletions

View File

@@ -82,6 +82,18 @@ function($ionicTabsDelegate, $ionicConfig, $ionicHistory) {
$scope.$hasTabsTop = isTabsTop && !isHidden;
});
function emitLifecycleEvent(ev, data) {
ev.stopPropagation();
var selectedTab = tabsCtrl.selectedTab();
if (selectedTab) {
selectedTab.$emit(ev.name.replace('NavView', 'View'), data);
}
}
$scope.$on('$ionicNavView.beforeLeave', emitLifecycleEvent);
$scope.$on('$ionicNavView.afterLeave', emitLifecycleEvent);
$scope.$on('$ionicNavView.leave', emitLifecycleEvent);
$scope.$on('$destroy', function() {
// variable to inform child tabs that they're all being blown away
// used so that while destorying an individual tab, each one

View File

@@ -315,6 +315,12 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe
scope.$emit('$ionicView.leave', leavingData);
}
}
} else if (scope && leavingData && leavingData.viewId) {
scope.$emit('$ionicNavView.' + step + 'Leave', leavingData);
if (step == 'after') {
scope.$emit('$ionicNavView.leave', leavingData);
}
}
},