likeastore / ngDialog

Modals and popups provider for Angular.js applications
http://likeastore.github.io/ngDialog
3.14k stars 692 forks source link

How to close dialog opened by openConfirm #600

Open JeffinBao opened 4 years ago

JeffinBao commented 4 years ago

Since openConfirm() returns a promise, I can not get dialog id as open() method returning an object. Then how can I only close the dialog created by openConfirm() method in JS? I've tried a lot of approaches, all of them didn't work.

JeffinBao commented 4 years ago

I found one working approach which is to register an event listener and record the dialog id. This approach was found in the documentation.

$rootScope.$on('ngDialog.opened', function (e, $dialog) { console.log('ngDialog opened: ' + $dialog.attr('id')); });

However, I wonder if there is another way to close the dialog opened by openConfirm() method? By the way, I am opening the dialog in an interceptor, not a controller. Any idea would be appreciated. Thanks!