Reputation: 36209
I don't if this is something I did, but once I upgraded to Angular 1.3, the form is no longer defined in my scope. My HTML is
<div some-dir>
<form name="myForm">
<!-- Form stuff here -->
<button ng-click="submit();">
</form>
</div>
The submit
function is
scope.submit = function() {
console.log(scope.myForm);
}
And this returns undefined. I have no ng-if
or ng-repeat
anywhere. There is only one directive and one scope in this specific directive. Again, this was all working until I upgraded to Angular 1.3
Upvotes: 2
Views: 5307
Reputation: 4595
In my case it happened that my form was nested within another form.
So once I switched the <form name="myForm">
to <ng-form name="myForm" ...>
the form was defined.
See ng-form docs.
Upvotes: 2
Reputation: 1144
The problem can be solved by scoping form data into some scope object:
<form name="myForms.firstForm">
<!-- Form stuff here -->
<button ng-click="submit();">
</form>
And than:
scope.myForms = {};
scope.submit = function() {
console.log(scope.myForms.firstForm);
}
Some more info in this comment.
Upvotes: 10
Reputation: 11
Got the same problem and fixed by declaring the controller in the html template that contains the form. So you form declaration would become:
<form name="myForm" ng-controller="SomeController">
New "feature" of 1.3, probably..
Upvotes: 1