title: AngularJs - How do I get my current form in my controller?
body: <p>I have been following this <a href="https://stackoverflow.com/questions/16168355/angularjs-server-side-validation-and-client-side-forms]">AngularJS - Server side validation and client side forms</a> SO question, but I can't seem to get it to work.</p>
  
  <p>Given the following code:</p>
  
  <pre><code>&lt;div ng-controller='LoginCtrl'&gt;
      &lt;form id="myForm" onsubmit="return false;" novalidate&gt;
          &lt;input type="text" ng-model="model.userName" /&gt;
          &lt;button ng-click="login()"&gt;Login&lt;/button&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>app.controller('LoginCtrl', ['$scope', function ($scope) {
      $scope.model = { userName: '' };
  
      $scope.login = function () {
          console.log($scope.myForm);  // &lt;-- this is undefined
      };
  }]);
  </code></pre>
  
  <p>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.</p>
  
  <p>What am I doing wrong here?</p>