7

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' });
};
});
sukesh
  • 2,379
  • 12
  • 56
  • 111

3 Answers3

13

Try passing 'preCloseCallback':-

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

Hope this helps!

amitthk
  • 1,115
  • 1
  • 11
  • 19
2

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
});
Szabolcs Páll
  • 1,402
  • 6
  • 25
  • 31
1
 $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.

Brendan Green
  • 11,676
  • 5
  • 44
  • 76
Rahul
  • 211
  • 2
  • 10
  • 1
    Thank you. I tried backdrop but the modal still closes when clicked anywhere outside it. – sukesh Feb 05 '15 at 10:45
  • 4
    ngDialog.open({ template: 'popupTmpl.html', closeByDocument : false, preCloseCallback:function(){ /* Do something here*/} }); Do this and let me know it works or not. My skype: er.chourasiya – Rahul Feb 05 '15 at 10:58
  • Ok that's great. https://github.com/likeastore/ngDialog this might be useful to you. – Rahul Feb 05 '15 at 18:02