Search⌘ K
AI Features

Opening the Modal

Understand how to control modal visibility in Angular by toggling it on form submission. Learn to use the ngIf directive and prevent default form behavior to manage modal display within advanced components.

Currently, the modal is, by default, opened when we visit the contact page. We’ll want to change this behavior by opening the modal when the form is submitted. We’ll also need a way to close the modal besides navigating to a different page.

We’ll start by opening the modal. It’s going to be rather simple to toggle its visibility. We’ll use the ngIf directive to help us add/remove the ModalComponent.

Form

...