Skip to content

Commit

Permalink
fix: transitioning to same modal state with different params - #13
Browse files Browse the repository at this point in the history
  • Loading branch information
nonplus committed Aug 26, 2016
1 parent b51576b commit 7036434
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/angular-ui-router-uib-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ angular.module("ui.router.modal", ["ui.router"])
throw new Error("Invalid modal state definition: The onExit setting may not be specified.");
}

var modalInstance;
var openModal;

// Get modal.resolve keys from state.modal or state.resolve
var resolve = (Array.isArray(options.modal) ? options.modal : []).concat(Object.keys(options.resolve || {}));
Expand All @@ -33,10 +33,10 @@ angular.module("ui.router.modal", ["ui.router"])
}
}

modalInstance = $uibModal.open(options);
var thisModal = openModal = $uibModal.open(options);

modalInstance.result['finally'](function() {
if (modalInstance) {
openModal.result['finally'](function() {
if (thisModal === openModal) {
// Dialog was closed via $uibModalInstance.close/dismiss, go to our parent state
$state.go($state.get("^", stateName).name);
}
Expand All @@ -47,10 +47,10 @@ angular.module("ui.router.modal", ["ui.router"])
options.onEnter.$inject = inject.concat(resolve);

options.onExit = function() {
if (modalInstance) {
if (openModal) {
// State has changed while dialog was open
modalInstance.close();
modalInstance = null;
openModal.close();
openModal = null;
}
};

Expand Down

0 comments on commit 7036434

Please sign in to comment.