<form name="v" ng-submit="submit()" ng-controller="ExampleController">
Enter text and hit enter OUTER FORM:
<input type="text" ng-model="text" name="texta" />
<input type="submit" id="submit" value="Submit" />
<pre>list={{list}}</pre>
<form name="x" ng-submit="submitInner()">
Enter text and hit enter INNER FORM:
<input type="text" ng-model="textInner" name="text" />
<input type="submit" id="submits" value="Submit" />
<pre>lists={{listInner}}</pre>
</form>
</form>
example : Plnkr
I have an angular form
inside a form
. When I select inner field and hit enter, the outer form submit action is called.
I am expecting it to call the inner form submit action
Am I expecting wrong, if yes why? and how to achieve the intended behavior
Below is from angular doc(https://docs.angularjs.org/api/ng/directive/form):
If a form has only one input field then hitting enter in this field triggers form submit (ngSubmit)
if a form has 2+ input fields and no buttons or input[type=submit] then hitting enter doesn't trigger submit
if a form has one or more input fields and one or more buttons or input[type=submit] then hitting enter in any of the input fields will trigger the click handler on the first button or input[type=submit] (ngClick) and a submit handler on the enclosing form (ngSubmit)