title: Angular setValidity not working?
body: <p>I first using <code>setValidity</code> to make a directive in Angular.but not as my expected,here is my code:</p>
  
  <pre><code>angular.module('myApp', [])
  .controller('ctrl',function($scope){
    $scope.pw='';
  })
  .directive('pwCheck', function(){
    return {
       require: 'ngModel',
      link: function (scope, elem, attrs, ctrl) {
      elem.on('keyup', function () {
          scope.$apply(function () {
          var len = elem.val().length;
  
              if(len===0){
                   ctrl.$setValidity('zero',true);
              } else if(len&gt;1 &amp;&amp; len&lt;6){
                   ctrl.$setValidity('one',true);
              } else {
                    ctrl.$setValidity('two',true);
              }
  
          });
          });
       }
      };
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;body ng-controller="ctrl"&gt;
    &lt;form id="myForm" name="myForm"&gt;
      &lt;input type="text" ng-model="pw" pw-check /&gt;
  
      {{myForm.$error}}
      &lt;div class="msg-block" ng-show="myForm.$error"&gt;
        &lt;span class="msg-error" ng-show="myForm.pw.$error.zero"&gt;
            Input a password.
        &lt;/span&gt;
        &lt;span class="msg-error" ng-show="myForm.pw.$error.one"&gt;
            Passwords too short.
        &lt;/span&gt;
        &lt;span class="msg-error" ng-show="myForm.pw.$error.two"&gt;
            Great.
        &lt;/span&gt;
     &lt;/div&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Online Demo:</p>
  
  <p><a href="http://jsbin.com/cefecicu/1/edit" rel="nofollow">http://jsbin.com/cefecicu/1/edit</a></p>