I have been following this AngularJS - Server side validation and client side forms SO question, but I can't seem to get it to work.
Given the following code:
<div ng-controller='LoginCtrl'>
<form id="myForm" onsubmit="return false;" novalidate>
<input type="text" ng-model="model.userName" />
<button ng-click="login()">Login</button>
</form>
</div>
and
app.controller('LoginCtrl', ['$scope', function ($scope) {
$scope.model = { userName: '' };
$scope.login = function () {
console.log($scope.myForm); // <-- this is undefined
};
}]);
The console.log shows undefined. I thought that by including the form as a child of the controller div, angular automatically included the form as a variable in my scope.
What am I doing wrong here?