I have seen different ways of implementing a form and its logic behind to interact with the controller, and I would like to know what is the best approach to follow.
Example:
<form name="myForm" ng-submit="submit(user)">
username: <input name="username" ng-model="user.username">
age: <input name="age" ng-model="user.age">
</form>
In that example, our submit() method in the controller would have 3 ways of extracting username and age from the form:
- Use the
$scope.myFormobject. This object has also information related to form validation. - Use the
$scope.userobject. - Use the
uservariable passed to thesubmit()method.
So my question is, what is the best practice?