refactor(ionNavButtons): remove elements from bar on scope destroy

This commit is contained in:
Andy Joslin
2014-03-17 12:18:08 -06:00
parent 6662f6effd
commit cdcbea3860
2 changed files with 5 additions and 5 deletions

View File

@@ -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]);
}));

View File

@@ -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);
});