Reputation: 1335
I imagine this is quite a simple answer, but I can't find the right syntax.
I have my modal opening like so,
$scope.assignment = function (groupId) {
var modalInstance = $modal.open({
templateUrl: 'assignment_form',
controller: 'GroupsAssignmentController',
windowClass: 'modal-user-window',
resolve: {
id: function () {
return groupId;
}
}
});
All I want to do is have a function run when the modal is closed so my main screen is updated.
I'm not sure if this involves $modal.close?
$modal.close({
//getAllGroups();
});
Upvotes: 6
Views: 14522
Reputation: 28445
modalInstance.result.finally(function(){
// do your work here
});
You can also use then
then(successCallback, errorCallback, notifyCallback)
SuccessCallback is excetuted when the promise is resolved. errorCallback is executed when the promise is rejected. Finally notifyCallback is executed when notified.
In the case of angular-ui's modal, clicking on the backdrop will result in a rejected promise. With this in mind, your code could be changed to :
modalInstance.result.then(function () {
alert('Modal success');
}, function () {
alert('Modal dismissed');
});
Upvotes: 10