NgDialog - closeModal event - angularjs

Is there any event that fires when a popup closes.

Modal opens on click event. The modal has a close button, but also closes when the user clicks anywhere outside the modal div.

I would like to perform some actions when the popup closes. I know how to write a function when I click this close button, but what if the modal closes by some other action.

app.controller('MainCtrl', function ($scope, ngDialog) { $scope.clickToOpen = function () { ngDialog.open({ template: 'popupTmpl.html' }); }; }); 
+6
source share
3 answers

Try passing 'preCloseCallback': -

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

Hope this helps!

+12
source
  $modal.open({ ... // other options backdrop : 'static' }); 

The exact answer. Just use backdrop : 'static' and your modal screen will close only by pressing the close button. And yes, that was a big question. Many developers make such a stupid mistake, but you are not from them. If this does not help, let me answer. There are many ways to do this.

+1
source

Just put closeByDocument: false inside dialog.open so that the dialog does not close when the user clicks anywhere outside the modal div.

Code example

 ngDialog.open({ id: 'fromAService', template: 'firstDialogId', controller: 'InsideCtrl', data: { foo: 'from a service' }, closeByDocument: false }); 
+1
source

Source: https://habr.com/ru/post/982027/


All Articles