You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 29, 2019. It is now read-only.
I have a case when a message might come to the website via sockets and based on that message I need to close a particular modal (not all opened modals) if it's open.
For this I propose to add an optional parameter id to the modal:
var modalInstance = {
id: modalOptions.id,
result: modalResultDeferred.promise,
opened: modalOpenedDeferred.promise,
close: function (result) {
$modalStack.close(modalInstance, result);
},
dismiss: function (reason) {
$modalStack.dismiss(modalInstance, reason);
}
};
and add two more methods to $modalStack:
$modalStack.getAll = function () {
return openedWindows.keys();
};
$modalStack.closeById = function(id, result) {
var modalInstance = null;
var opened = $modalStack.getAll();
for (var i = 0, l = opened.length; i < l; i++) {
if (opened[i].id == id) {
modalInstance = openedWindows.get(opened[i]);
break;
}
}
if (modalInstance) {
$modalStack.close(modalInstance.key, result);
}
}
This way developer will be able to achieve this functionality with ease.