Is it possible to submit a form that does not have submit button (by pressing enter) example :
<form [ngFormModel]="xxx" (ngSubmit)="xxxx()">
<input [(ngModel)]="lxxR" ngControl="xxxxx"/>
</form
Is it possible to submit a form that does not have submit button (by pressing enter) example :
<form [ngFormModel]="xxx" (ngSubmit)="xxxx()">
<input [(ngModel)]="lxxR" ngControl="xxxxx"/>
</form
Always use keydown.enter instead of keyup.enter to avoid lagging.
and function inside component.ts
If you want to include both simpler than what I saw here, you can do it just by including your button inside form.
Example with a function sending a message:
You can choose between clicking on the button or pressing enter key.
If you want to include both - accept on enter and accept on click then do -
Hopefully this can help somebody: for some reason I couldn't track because of lack of time, if you have a form like:
when you hit the
Enter
button, theclearForm
function is called, even though the expected behaviour was to call thedoSubmit
function. Changing theClear
button to a<a>
tag solved the issue for me. I would still like to know if that's expected or not. Seems confusing to meJust simply add
(keyup.enter)="yourFunction()"
this should work and already mentioned in many answers, however that should be present on form tag and not on button.