diff --git a/js/angular/service/modal.js b/js/angular/service/modal.js index af8c20bf3d..aa33c4a96a 100644 --- a/js/angular/service/modal.js +++ b/js/angular/service/modal.js @@ -128,12 +128,10 @@ function($rootScope, $document, $compile, $timeout, $ionicPlatform, $ionicTempla .removeClass('ng-leave ng-leave-active'); self._isShown = true; - self._deregisterBackButton = self.hardwareBackButtonClose ? - $ionicPlatform.registerBackButtonAction( - angular.bind(self, self.hide), - PLATFORM_BACK_BUTTON_PRIORITY_MODAL - ) : - angular.noop; + self._deregisterBackButton = $ionicPlatform.registerBackButtonAction( + self.hardwareBackButtonClose ? angular.bind(self, self.hide) : angular.noop, + PLATFORM_BACK_BUTTON_PRIORITY_MODAL + ); self._isOpenPromise = $q.defer(); diff --git a/test/unit/angular/directive/gestures.js b/test/unit/angular/directive/gestures.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/unit/angular/service/modal.unit.js b/test/unit/angular/service/modal.unit.js index e77672a2af..cbf926d3f7 100644 --- a/test/unit/angular/service/modal.unit.js +++ b/test/unit/angular/service/modal.unit.js @@ -106,10 +106,14 @@ describe('Ionic Modal', function() { var instance = modal.fromTemplate(template, { hardwareBackButtonClose: false }); - spyOn($ionicPlatform, 'registerBackButtonAction'); + spyOn($ionicPlatform, 'registerBackButtonAction').andCallThrough(); instance.show(); timeout.flush(); - expect($ionicPlatform.registerBackButtonAction).not.toHaveBeenCalled(); + expect($ionicPlatform.registerBackButtonAction).toHaveBeenCalledWith(jasmine.any(Function), PLATFORM_BACK_BUTTON_PRIORITY_MODAL); + + ionicPlatform.hardwareBackButtonClick(); + + expect(instance.isShown()).toBe(true); })); it('should call _deregisterBackButton on hide', function() {