mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(ionNavButtons): remove elements from bar on scope destroy
This commit is contained in:
@@ -42,24 +42,24 @@ describe('ionNavButtons directive', function() {
|
||||
expect(rightButtons.text().trim()).toEqual('135');
|
||||
});
|
||||
|
||||
it('left should destroy contents on element destroy', inject(function($animate) {
|
||||
it('left should destroy contents on scope destroy', inject(function($animate) {
|
||||
spyOn($animate, 'leave');
|
||||
|
||||
var el = setup('side="left" ng-init="items=[1,2]"', '<button ng-repeat="i in items">{{i}}</button>');
|
||||
var leftButtons = el.controller('ionNavBar').leftButtonsElement.children();
|
||||
expect(leftButtons.text().trim()).toEqual('12');
|
||||
el.remove();
|
||||
el.scope().$destroy();
|
||||
expect($animate.leave).toHaveBeenCalled();
|
||||
expect($animate.leave.mostRecentCall.args[0][0]).toBe(leftButtons[0]);
|
||||
}));
|
||||
|
||||
it('right should destroy contents on element destroy', inject(function($animate) {
|
||||
it('right should destroy contents on scope destroy', inject(function($animate) {
|
||||
spyOn($animate, 'leave');
|
||||
|
||||
var el = setup('side="right" ng-init="items=[1,2]"', '<button ng-repeat="i in items">{{i}}</button>');
|
||||
var rightButtons = el.controller('ionNavBar').rightButtonsElement.children();
|
||||
expect(rightButtons.text().trim()).toEqual('12');
|
||||
el.remove();
|
||||
el.scope().$destroy();
|
||||
expect($animate.leave).toHaveBeenCalled();
|
||||
expect($animate.leave.mostRecentCall.args[0][0]).toBe(rightButtons[0]);
|
||||
}));
|
||||
2
js/ext/angular/src/directive/ionicNavBar.js
vendored
2
js/ext/angular/src/directive/ionicNavBar.js
vendored
@@ -391,7 +391,7 @@ function($ionicViewService, $rootScope, $animate, $compile, $parse) {
|
||||
|
||||
//When our ion-nav-buttons container is destroyed,
|
||||
//destroy everything in the navbar
|
||||
$element.on('$destroy', function() {
|
||||
$scope.$on('$destroy', function() {
|
||||
$animate.leave(clone);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user