Is there any event that fires when the popup is closed.
The modal opens on a click event. The modal has a close button, but also gets closed when user clicks anywhere outside the modal div.
Would like to perform some actions, whenever the popup is closed. I know how to write the function on click of that close button, but what if the modal is being closed by some other action.
app.controller('MainCtrl', function ($scope, ngDialog) {
$scope.clickToOpen = function () {
ngDialog.open({ template: 'popupTmpl.html' });
};
});
Try passing 'preCloseCallback':-
ngDialog.open({ template: 'popupTmpl.html', preCloseCallback:function(){ /* Do something here*/} });
Hope this helps!
Just put closeByDocument : false inside the dialog.open so that dialog will not close when user clicks anywhere outside the modal div.
Example Code
ngDialog.open({
id: 'fromAService',
template: 'firstDialogId',
controller: 'InsideCtrl',
data: { foo: 'from a service' },
closeByDocument: false
});
$modal.open({
... // other options
backdrop : 'static'
});
Accurate answer. Just use backdrop : 'static'
and your modal will close only by clicking on the close button. And yes, it was a great question. Many developers do such kind of silly mistake but you are not from them. If it doesn't help then let me reply. There are many ways to do so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With