How to check if an ionicModal is open?

0

Hello, How to tell if an ionicModal is open? I need to check if an ionicModal is open, if it needs to close it so it does not open two ionicModal at the same time

    
asked by anonymous 26.07.2017 / 18:40

1 answer

1

As documentation , every time you make a call

$ionicModal.fromTemplate(...)
$ionicModal.fromTemplateUrl(...)

you'll receive a new promise from ionicModal . The method you are looking for is the isShown .

if (ionicModal.isShown()) { // se a janela está visível ...
    ionicModal.hide(); // fecha ...
}
What can happen is that more than one place might want to create these modals and you will not have access to those references, in which case you need to implement an own mechanism to control how many modals are open (make a factory that instance these modalities and save the references, or use the events that the $ ionicModal issues ) and / or you want to override a modal.

    
28.07.2017 / 00:50