3

I'm migrating from AngularJS 1.1.15 to 1.3.15 and my current issue is getting $modal to work instead of $dialog.

If anyone has any helpful links regarding the migration would be appreciated :) I'm currently handling it per-bug fix.

To my current question: My previous code was looking like:

var msgBox = $dialog.dialog({ ... });
msgBox.open().then(......);

And I changed it to

var msgBox = $modal.open(...);
msgBox.opened.then(......);

So now the issue i'm experiencing is having an IF:

if (msgBox && msgBox.isOpen())

How do I implement it with $modal? From the documentation here I don't see there is a replacement for isOpen.

On most stackoverflow questions I saw people suggesting to use jQuery, but its pretty messy and I rather avoid that.

Thanks for the help

AlexD
  • 4,062
  • 5
  • 38
  • 65

1 Answers1

3

I'm not aware of any "out of the box" solution for this, so I'm checking if a $modal is opened or closed by checking the statuses from the $modal.result promise. Here they are:

  • Pending (0)
  • Resolved (1)
  • Rejected (2)

You can check if a modal is open like this:

$modal.result.$$state.status === 1;

When you close it, the status changes to 2.

Hope it helps.

darksoulsong
  • 13,988
  • 14
  • 47
  • 90