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

Commit

Permalink
fix(modal): destroy modal scope after animation end
Browse files Browse the repository at this point in the history
Fixes #1643
  • Loading branch information
pkozlowski-opensource committed Jan 22, 2014
1 parent 6fb6a76 commit dfc36fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/modal/modal.js
Expand Up @@ -141,7 +141,10 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
openedWindows.remove(modalInstance);

//remove window DOM element
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, checkRemoveBackdrop);
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, function() {
modalWindow.modalScope.$destroy();
checkRemoveBackdrop();
});
body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
}

Expand Down
13 changes: 12 additions & 1 deletion src/modal/test/modal.spec.js
Expand Up @@ -335,7 +335,7 @@ describe('$modal', function () {

describe('scope', function () {

it('should custom scope if provided', function () {
it('should use custom scope if provided', function () {
var $scope = $rootScope.$new();
$scope.fromScope = 'Content from custom scope';
open({
Expand All @@ -344,6 +344,17 @@ describe('$modal', function () {
});
expect($document).toHaveModalOpenWithContent('Content from custom scope', 'div');
});

it('should create and use child of $rootScope if custom scope not provided', function () {

var scopeTailBefore = $rootScope.$$childTail;

$rootScope.fromScope = 'Content from root scope';
open({
template: '<div>{{fromScope}}</div>'
});
expect($document).toHaveModalOpenWithContent('Content from root scope', 'div');
});
});

describe('keyboard', function () {
Expand Down

0 comments on commit dfc36fd

Please sign in to comment.