Hi
When i click on Add Modal is not opening. Below is the Dynamic Table Component HTML.
Code
addTypeScript
openDialog($event:Event){
this.openModal.emit($event);
debugger;
}Code
Product Form
-->
Product Name
This is required
Minimum length is 4
-->
Product Description
Product Image
Cancel
SaveThanks

Naimish MakwanaRank #324 · 7.7K reputationPosted Jul 9, 2024, 3:38 AM EDT
It seems like you’re trying to open a modal dialog when the “Add” button is clicked, but it’s not working. Here are a few things you could check:
Event Emitter: Ensure that the
openModalevent emitter in your component is correctly emitting the event. You can check this by subscribing to theopenModalevent in the parent component and logging the event.Dialog Component: Make sure that the dialog component (the content inside
... ) is correctly set up to display as a modal. This usually involves using a service provided by your UI library (like MatDialog in Angular Material) to open the dialog.Dialog Service: Check if you have correctly injected the dialog service (like MatDialog) in your component and if you’re calling the appropriate method to open the dialog.
Button Click: Ensure that the click event on the button is correctly wired up to call the
openDialogmethod.If you’re using Angular Material, the code to open the dialog should look something like this:
import { MatDialog } from '@angular/material/dialog'; constructor(private dialog: MatDialog) { } openDialog(event: Event) { const dialogRef = this.dialog.open(DialogContentComponent); dialogRef.afterClosed().subscribe(result => { console.log(`Dialog result: ${result}`); }); }In this example,
DialogContentComponentis the component that contains the dialog content. You would replace this with the component that contains your form.Remember to import
MatDialogModulein your module file.I hope this helps!
Thanks