Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngDialog - closeModal event - angularjs

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' });
};
});
like image 419
Qwerty Avatar asked Feb 05 '15 09:02

Qwerty


3 Answers

Try passing 'preCloseCallback':-

ngDialog.open({ template: 'popupTmpl.html', preCloseCallback:function(){ /* Do something here*/} });

Hope this helps!

like image 133
amitthk Avatar answered Nov 13 '22 00:11

amitthk


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
});
like image 39
Dayakar Reddy Avatar answered Nov 13 '22 01:11

Dayakar Reddy


 $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.

like image 34
Rahul Avatar answered Nov 13 '22 00:11

Rahul