Check if $ modal like $ dialog.isOpen is open
I am migrating from AngularJS 1.1.15 to 1.3.15 and my current problem is getting $ modal to work instead of $ dialog.
If anyone has any helpful links regarding migration you will be greatly appreciated :) I am currently processing this fix for every bug.
To my current question: My previous code looked like this:
var msgBox = $dialog.dialog({ ... });
msgBox.open().then(......);
And I changed it to
var msgBox = $modal.open(...);
msgBox.opened.then(......);
So now the problem I am facing has IF:
if (msgBox && msgBox.isOpen())
How do I implement it using $ modal? From here's documentation I don't see a replacement for isOpen.
In most stackoverflow questions, I've seen people suggest using jQuery, but it's pretty messy and I'd rather avoid it.
thanks for the help
source to share
I don't know of any out-of-the-box solution for this, so I check if the mod is open or not by checking the statuses from the promise $modal.result
. Here they are:
- Waiting (0)
- Solved (1)
- Rejected (2)
You can check if the modal view is open:
$modal.result.$$state.status === 1;
When you close it status
will change to 2
.
Hope it helps.
source to share