Skip to content

Commit c4ca7a8

Browse files
author
Adam Bradley
committed
fix(modal): Fix removing modal from DOM on .remove(), closes #755
1 parent 41afcdc commit c4ca7a8

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Diff for: js/ext/angular/src/service/ionicModal.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
2626

2727
$timeout(function(){
2828
element.addClass('ng-enter-active');
29-
self.scope.$parent.$broadcast('modal.shown');
29+
self.scope.$parent && self.scope.$parent.$broadcast('modal.shown');
3030
}, 20);
3131

3232
self._deregisterBackButton = $ionicPlatform.registerBackButtonAction(function(){
@@ -65,7 +65,8 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
6565

6666
$timeout(function(){
6767
self.scope.$destroy();
68-
}, 500);
68+
self.el && self.el.parentElement && self.el.parentElement.removeChild(self.el);
69+
}, 1000);
6970
},
7071

7172
isShown: function() {

Diff for: js/ext/angular/test/modal.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<div class="modal" ng-controller="ModalCtrl">
2727
<header class="bar bar-header bar-assertive">
2828
<h1 class="title">New Contact</h1>
29-
<button class="button button-clear button-primary" ng-click="close()">Cancel</button>
3029
</header>
3130
<ion-content has-header="true">
3231
<div class="padding">
@@ -43,7 +42,8 @@ <h1 class="title">New Contact</h1>
4342
<span class="input-label">Email</span>
4443
<input type="text" placeholder="">
4544
</label>
46-
<button class="button button-block button-positive" ng-click="closeModal()">Create</button>
45+
<button class="button button-block button-positive" ng-click="hideModal()">Hide Modal</button>
46+
<button class="button button-block button-positive" ng-click="removeModal()">Remove Modal</button>
4747
<button class="button button-block button-positive" ng-click="openActionSheet()">ActionSheet</button>
4848
</div>
4949
</div>
@@ -72,9 +72,6 @@ <h1 class="title">New Contact</h1>
7272
$scope.openModal = function() {
7373
$scope.modal.show();
7474
};
75-
$scope.closeModal = function() {
76-
$scope.modal.hide();
77-
};
7875
$ionicModal.fromTemplateUrl('modal.html', function(modal) {
7976
$scope.modal = modal;
8077
}, {
@@ -85,9 +82,12 @@ <h1 class="title">New Contact</h1>
8582
})
8683

8784
.controller('ModalCtrl', function($scope, $ionicActionSheet) {
88-
$scope.close = function() {
85+
$scope.hideModal = function() {
8986
$scope.modal.hide();
90-
}
87+
};
88+
$scope.removeModal = function() {
89+
$scope.modal.remove();
90+
};
9191

9292
$scope.openActionSheet = function() {
9393
$ionicActionSheet.show({

0 commit comments

Comments
 (0)