mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(ionTabBar): remove tab.shown and tab.hidden events
Instead, use `on-select` and `on-deselect` attribute callbacks.
Alternatively, listen for $scope.$on('$destroy') in a controller inside
your tab.
This commit is contained in:
6
js/ext/angular/src/directive/ionicTabBar.js
vendored
6
js/ext/angular/src/directive/ionicTabBar.js
vendored
@@ -218,8 +218,6 @@ function($scope, $ionicViewService, $rootScope, $element) {
|
||||
*
|
||||
* Each ionTab has its own view history.
|
||||
*
|
||||
* Whenever a tab is shown or hidden, it will broadcast a 'tab.shown' or 'tab.hidden' event.
|
||||
*
|
||||
* @usage
|
||||
* ```html
|
||||
* <ion-tab
|
||||
@@ -308,9 +306,6 @@ function($rootScope, $animate, $ionicBind, $compile, $ionicViewService) {
|
||||
tabsCtrl.$tabsElement.append($compile(tabNavElement)($scope));
|
||||
|
||||
$scope.$watch('$tabSelected', function(value) {
|
||||
if (!value) {
|
||||
$scope.$broadcast('tab.hidden', $scope);
|
||||
}
|
||||
childScope && childScope.$destroy();
|
||||
childScope = null;
|
||||
childElement && $animate.leave(childElement);
|
||||
@@ -320,7 +315,6 @@ function($rootScope, $animate, $ionicBind, $compile, $ionicViewService) {
|
||||
childElement = tabContent.clone();
|
||||
$animate.enter(childElement, tabsCtrl.$element);
|
||||
$compile(childElement)(childScope);
|
||||
$scope.$broadcast('tab.shown', $scope);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -363,7 +363,6 @@ describe('tabs', function() {
|
||||
var contentScope = tabContent.scope();
|
||||
expect(tabContent.length).toBe(1);
|
||||
expect(tabContent.find('.inside-content').length).toBe(1);
|
||||
expect(tab.$broadcast).toHaveBeenCalledWith('tab.shown', tab);
|
||||
|
||||
spyOn(tabContent, 'remove');
|
||||
spyOn(contentScope, '$destroy');
|
||||
@@ -372,7 +371,6 @@ describe('tabs', function() {
|
||||
tab.$apply('$tabSelected = false');
|
||||
expect(tabContent.parent().length).toBe(0); //removed check
|
||||
expect(contentScope.$destroy).toHaveBeenCalled();
|
||||
expect(tab.$broadcast).toHaveBeenCalledWith('tab.hidden', tab);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user