From cdcbea38602799c1e54b631a70f12af27bee0df2 Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Mon, 17 Mar 2014 12:18:08 -0600 Subject: [PATCH] refactor(ionNavButtons): remove elements from bar on scope destroy --- .../ionicNavButtons.js => ionicNavButtons.unit.js | 8 ++++---- js/ext/angular/src/directive/ionicNavBar.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename js/ext/angular/test/directive/ionicNavButtons.js => ionicNavButtons.unit.js (91%) diff --git a/js/ext/angular/test/directive/ionicNavButtons.js b/ionicNavButtons.unit.js similarity index 91% rename from js/ext/angular/test/directive/ionicNavButtons.js rename to ionicNavButtons.unit.js index 89c1fe62bf..2dfc5d1625 100644 --- a/js/ext/angular/test/directive/ionicNavButtons.js +++ b/ionicNavButtons.unit.js @@ -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]"', ''); 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]"', ''); 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]); })); diff --git a/js/ext/angular/src/directive/ionicNavBar.js b/js/ext/angular/src/directive/ionicNavBar.js index fe8206ea91..99dec1854b 100644 --- a/js/ext/angular/src/directive/ionicNavBar.js +++ b/js/ext/angular/src/directive/ionicNavBar.js @@ -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); });