How to close ngDialog from angular controller

I need to open several ngDialog with the same identifier by clicking the close button, it should close only ngDialog currently open.

To close ngDialog, I need to trigger one event that collects data, then closes ngDialog.

+4
source share
5 answers

It depends if you try to close it (1) from your own controller or (2) the controller that creates it:

(1) From own controller:

scope.closeThisDialog(value);

see document: https://github.com/likeastore/ngDialog

(2) From the controller that starts it:

var dialog = ngDialog.open(); 
// for closing the dialog call dialog.close()

As mentioned by Satish Salvador in response.

Hurrah!

+6
source

ngDialog.open() var dialog = ngDialog.open(); dialog.close()

+3

.getOpenDialogs()

There is an object method ngDialogcalled getOpenDialogs. What could you do with this function, is to get a list of all open dialogs and close the one that interests you, calling .close()on the "selected".

+1
source

In some cases, you can avoid this problem by specifying disableAnimation options when creating a dialog:

ngDialog.open({
  template: 'template.html',
  appendClassName: 'ngdialog-custom',
  disableAnimation: true
});
0
source

Besides closeThisDialog()you can do:

vm.myDialog = ngDialog.open(... omissis ...);
...
vm.myDialog.close();

or

vm.myDialog = ngDialog.open(... omissis ...);
...
ngDialog.close(vm.myDialog.id);    
0
source

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


All Articles