Now, In this topic, we will discuss ViewController.What is ViewController in Ionic 3?
What is the use of ViewController in the application? How to close the modal in a proper way so that the application not get affected.
How to use ViewController in Ionic V3?
In to understand ViewController in ionic we have created a modal. If you want to close this modal you can simply write the below method as shown in the image.
The HTML is as follows :
The .ts file is as follows :
As shown in the above image we have to import ViewController from the default ionic-angular package. after that create a constructor for the same & dismiss the modal by using dismissModal() method.
How to close the modal in a proper way so that the application not get affected?
In some cases, you want to go for some other pages from the modal page. At that time if you write nav controller. push or set root method then in the background your modal is still present. In this case, you might be facing some issues like some buttons will not work or the toggle of the side menu will not work as modal is still present on UI. So, If you want to go to other pages you need to dismiss the view as shown in the above images.
So,that’s it about close the modal safely. See you later. 🙂