in angular how to submit form on click on radio button

Viewed 115

I'm using angular 13 for my project. I want to submit a feedback form by using the radio button. I don't want to give a specific button for submission.

1 Answers

If you put a this on your form tag:

<form ... #myForm (submit)="mySubmitFn($event)">

You could make use of the (change) or (input) on the input:

<input ... (change)="myHandler($event, myForm)" />

Within the handler you could make some check on the value if needed, and submit your form.

Alternatively, if no check is needed, instead of calling myHandler you could just:

<input ... (change)="myForm.submit()" />
Related