I’m trying to manually dismiss an ion-modal by calling the exposed dismiss method on the html element via vue refs, but it doesn’t seem to work and the ref doesn’t have access to the exposed method
Thanks, this works for that scenario, but it doesn’t explain why document.querySelector('ion-modal').dismiss() works, but not the ref version or how to call ionic component’s methods via refs in general
The documentation says to close modals using the modalController… for the other issues you will need to be more specific and maybe open a separate issue.
if you take a look at the documentation here ion-modal: Ionic Framework API Docs the component has exposed methods such as dismissonDidDismissonWillDismisspresent, etc… These methods should be exposed on the component itself directly.
Using the modal controller makes sense if I’m using the modal controller to display/create the modal, but in my case I’m relying on the component itself by rendering ion-modal in my template. so far I’m unable to call any methods mentioned in the documentation via vue refs.
The same argument holds for using any of the ionic components with vue refs in general not just ion-modal which happens to have an alternative solution via modalController
thank you very much! this worked.
but to me, this isn’t very intuitive.
i modalController.create({component:MyModal, …}) a modal, i want the ability to dismiss this modal from within MyModal. i thought to myself, “to dismiss within, MyModal component must have access to this created modal, right?”. but i just couldn’t find a way to do that. i just didn’t realize you can just import modalController independently and call dismiss() in it, the parent created modal would dismiss. this is like a static method in the OOP sense. to me, this really isn’t OOP intuition friendly.
thanks again, sorry about rant