Skip to content

Commit

Permalink
close modal on location change
Browse files Browse the repository at this point in the history
  • Loading branch information
joe.prisk committed Jan 16, 2015
1 parent 3bfb3e7 commit 0a9606c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
24 changes: 14 additions & 10 deletions dst/angular-modal-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,23 @@
};

// When close is resolved, we'll clean up the scope and element.
modal.close.then(function(result) {
// Clean up the scope
modalScope.$destroy();
// Remove the element from the dom.
modalElement.remove();
modal.close.then(closeModal);

// Remove bodyClass
if (options.bodyClass) {
body.removeClass(options.bodyClass);
deferred.resolve(modal);

function closeModal(result) {
// Clean up the scope
modalScope.$destroy();
// Remove the element from the dom.
modalElement.remove();

// Remove bodyClass
if (options.bodyClass) {
body.removeClass(options.bodyClass);
}
}
});

deferred.resolve(modal);
$rootScope.$on('$locationChangeSuccess', closeModal);

})
.catch(function(error) {
Expand Down
4 changes: 2 additions & 2 deletions dst/angular-modal-service.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dst/angular-modal-service.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions src/angular-modal-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,23 @@
};

// When close is resolved, we'll clean up the scope and element.
modal.close.then(function(result) {
// Clean up the scope
modalScope.$destroy();
// Remove the element from the dom.
modalElement.remove();
modal.close.then(closeModal);

// Remove bodyClass
if (options.bodyClass) {
body.removeClass(options.bodyClass);
deferred.resolve(modal);

function closeModal(result) {
// Clean up the scope
modalScope.$destroy();
// Remove the element from the dom.
modalElement.remove();

// Remove bodyClass
if (options.bodyClass) {
body.removeClass(options.bodyClass);
}
}
});

deferred.resolve(modal);
$rootScope.$on('$locationChangeSuccess', closeModal);

})
.catch(function(error) {
Expand Down

0 comments on commit 0a9606c

Please sign in to comment.