To fix the Angular error ‘Form submission canceled because the form is not connected’ with JavaScript, we add a submit button and a submit handler method to the form.
For instance, we write
<form #myForm="ngForm" (ngSubmit)="onSubmit()">
...
<button type="submit"></button>
</form>
to set (ngSubmit)
to call the onSubmit
method.
And we add a submit button in the form to trigger the submit event when we click it.