I have to implement a customized close dialog function for close button of ngDialog.
As per requirement in some cases (where there is a form) I have to show another ngDialog confirm popup asking if user really want to close the dialog or not so there are 2 options 'YES' and 'NO' which has this behavior.
I have tried it with preCloseCallback() method but somehow it did not worked for me as it does not wait for user confirmation. It is just like the function called on click of close and dialog closed or stays open depending on what I return from function immediately. If I don't return anything it assumes it to be true and closes the dialog.
Can anybody please let me know the way to solve this issue?
Here comes the nice solutions! It's bit hacky but worked perfectly for my case.
Step 1
Set
showCloseoption false while opening dialog.Step 2
Write common close button handling function
Step 3
Write a close function in controller to call factory function
Step 4
Add following line after defining header/title for HTML of ngDialog
Yooo... done the job...!!!
The best part of this solutions is a common code for closing any form, so once you done with factory function, you only need to add close button wherever required in HTML and add simple close function in controller