title: $setValidity function is not working as expected
body: <p>I have following code block in my Angular JS app. (this is a simplified version of huge code)</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form name="form-demo"&gt;
      &lt;input type="text" class="form-control" ng-model="modeldemo.date" ng-change="functiondemo1();"/&gt;
      &lt;input type="text" class="form-control" ng-model="modeldemo.date" ng-change="functiondemo2();"/&gt;
      &lt;select class="form-control" name="move" ng-model="modeldemo.move" ng-options="move.type for move in moveList" ng-required="true"&gt;
      &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JS file</strong></p>
  
  <pre><code>app.controller('moveCtrl', function($scope, $http, NgTableParams, $filter, $timeout) {
      $scope.moveList = {};
  
      $scope.functiondemo2 = function() {
          // get the data from server and assign to $scope.moveList
      }
  
      $scope.functiondemo1 = function() {
          $scope.modeldemo.move = null;
      }
  }
  </code></pre>
  
  <p>Dropdown should be cleared when first input box value changed. Dropdown values should be loaded when second input changed.</p>
  
  <p>But since <code>ng-required</code> attribute set as <code>true</code> in dropdown, when <code>functiondemo1</code> gets called, 'This field is required' error is shown.</p>
  
  <p>So I have modified the <code>functiondemo1</code> as follows.</p>
  
  <pre><code>$scope.functiondemo1 = function1() {
      $scope.modeldemo.move = null;
      $scope.form-demo.move.$setValidity("required", true);
  }
  </code></pre>
  
  <p>Then I'm getting following error in console.</p>
  
  <pre><code>angular.js:12477 TypeError: Cannot read property '$setValidity' of undefined
      at b.$scope.functiondemo1 (http://localhost:8080/js/script.js:63:16)
      at fn (eval at compile (http://localhost:8080/angular/angular.min.js:212:409), &lt;anonymous&gt;:4:590)
      at b.$eval (http://localhost:8080/angular/angular.min.js:133:221)
      at pre (http://localhost:8080/angular/angular.min.js:257:49)
      at aa (http://localhost:8080/angular/angular.min.js:73:90)
      at K (http://localhost:8080/angular/angular.min.js:61:354)
      at g (http://localhost:8080/angular/angular.min.js:54:410)
      at g (http://localhost:8080/angular/angular.min.js:54:433)
      at g (http://localhost:8080/angular/angular.min.js:54:433)
  </code></pre>
  
  <p>I have also checked the following and nothing worked.</p>
  
  <pre><code>$scope.form-demo.move.$setPristine();
  $scope.form-demo['move'].$setValidity("required", true);
  </code></pre>
  
  <p>Does anyone know how to fix this error?</p>