Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit dfc36fd

Browse files
fix(modal): destroy modal scope after animation end
Fixes #1643
1 parent 6fb6a76 commit dfc36fd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/modal/modal.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
141141
openedWindows.remove(modalInstance);
142142

143143
//remove window DOM element
144-
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, checkRemoveBackdrop);
144+
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, function() {
145+
modalWindow.modalScope.$destroy();
146+
checkRemoveBackdrop();
147+
});
145148
body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
146149
}
147150

src/modal/test/modal.spec.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ describe('$modal', function () {
335335

336336
describe('scope', function () {
337337

338-
it('should custom scope if provided', function () {
338+
it('should use custom scope if provided', function () {
339339
var $scope = $rootScope.$new();
340340
$scope.fromScope = 'Content from custom scope';
341341
open({
@@ -344,6 +344,17 @@ describe('$modal', function () {
344344
});
345345
expect($document).toHaveModalOpenWithContent('Content from custom scope', 'div');
346346
});
347+
348+
it('should create and use child of $rootScope if custom scope not provided', function () {
349+
350+
var scopeTailBefore = $rootScope.$$childTail;
351+
352+
$rootScope.fromScope = 'Content from root scope';
353+
open({
354+
template: '<div>{{fromScope}}</div>'
355+
});
356+
expect($document).toHaveModalOpenWithContent('Content from root scope', 'div');
357+
});
347358
});
348359

349360
describe('keyboard', function () {

0 commit comments

Comments
 (0)