title: Getting form validation state inside angularjs controller
body: <p>I am able to validate my form element 'name'd 'username'. </p>
  
  <pre><code>ng-class="{ 'has-error': form.username.$dirty &amp;&amp; form.username.$invalid }"
  </code></pre>
  
  <p>But I cannot get this info inside a controller. Is this possible?</p>
  
  <p>I want to do something like this:</p>
  
  <pre><code>mycontroller.controller('mycontroller', function ($scope){
  
      $scope.isusernameinvalid = $scope.form.username.$dirty &amp;&amp; $scope.form.username.$invalid;
  });
  </code></pre>
  
  <p>And use the isusernameinvalid (true/false) to toggle class</p>
  
  <pre><code>ng-class="{ 'has-error': isusernameinvalid }"
  </code></pre>
  
  <p>I know "form" is not a $scope variable, and hence inaccessible.</p>
  
  <p>How do i access the validation state/class info over here?</p>