Hi
I have below code . Modal should open on click of button but it already gets displayed on page.
Student Portal
Student Name
Mobile No
Email
City , State , PinCode
Address
Thanks
Naimish MakwanaPosted May 2, 2024, 4:49 AM
In Angular, you would typically use a component-based approach to handle modals. However, if you want to use Bootstrap modal in Angular, you can do so by using
*ngIfdirective to conditionally render the modal based on a property in your component.Here’s how you can modify your code:
First, in your component TypeScript file, define a property
showModaland a methodopenModal():Then, in your HTML, use the
*ngIfdirective to conditionally render the modal:Now, the modal will only be displayed when
showModalistrue, which happens when you click the “Add New” button and theopenModal()method is called.Thanks
Jignesh KumarPosted May 2, 2024, 4:05 AM
Hello Ramco,
add *ngIf for your model div
In your student component, you can add your methods to open, close and model hide property,