Fix Angular1.* ng-form & ng-submit issues. AngularJS by default doesn't handle <ng-form> the way a typical <form> is handled, Enter keypress doesn't submit, ng-submit also doesn't work with it. Fix all of those issues with this directive override.
Hi @MarkPieszak I found this repo while investigating the issue of ngForm submission for AngularJS core, and if this can be handled reliably by a third party directive. It's cool to see that this works. I've found a few issues though, and I know that this is a low activity repo, but maybe we can work on them together.
Submission rules for Enter / click doesn'T follow HTML spec. Since we want to follow regular form element rules, the rules need to be a bit more refined:
when there is more than one input element in the form, and no submit button, Enter should not submit the form
when there are multiple submit buttons, all of them should submit the form on click (atm only the first one that is found gets the click handler)
buttons without a type must also be considered submit buttons
Implementation issues:
finding the submit button doesn't account for dynamically generated buttons
calling the ngSubmit function should trigger an apply like it does in the regular form
"submit event" should call formController.$setSubmitted() instead of setting the classes and props manually
interop with regular forms is unclear. Imo, if you have only a single form, then you should use the regular <form> attribute. If you have a parent <form> or <ng-form>, then it shouldn't prevent the events from bubbling up, imo. It should only do that if the form if the form is not attached to the parent (a state that doesn't currently exist in AngularJS).