I have a mat-dialog-box where on click event it closes the dialog but I want it to work on Enter press also. Is there any way to do so?
I have tried using a form but didn't work. Below is my solution what I tried to use:
HTML
<form (submit)="doAction()">
<button type="submit">Add</button>
</form>
TS
doAction() {
this.dialogRef.close({ event: this.action, data: this.local_data });
}
But the Enter event is not occurring though on click it's submitting the data. Also for normal forms (which is not in a dialog) works on Enter press if I take the above HTML approach.
Can anyone suggest the issue?