title: angularjs input field directive isn't clearing errors when scope changes value
body: <p>I have a directive designed to impose date range restrictions on a date input field (earliest and latest).  Here is the directive below, I am using the momentjs library to do my date comparison:</p>
  
  <pre><code>.directive('startDate', function () {
  return {
      require: 'ngModel',
      link: function (scope, element, attrs, ctrl) {
          console.log(arguments);
          var compareStartDates = function (value) {
              var startDateCompare = moment((attrs.startDate ? scope.$eval(attrs.startDate) : '1901-01-01'), 'YYYY-MM-DD');
              if (startDateCompare &amp;&amp; startDateCompare.isValid() &amp;&amp; value &amp;&amp; value.match(/\d{4}\-?\d{2}\-?\d{2}/g)) {
                  var valueMoment = moment(value, 'YYYY-MM-DD');
                  if (valueMoment &amp;&amp; valueMoment.isValid() &amp;&amp; valueMoment &lt; startDateCompare) {
                      ctrl.$setValidity('startdate', false);
                      ctrl.$error['startdate'] = true;
                      return undefined;
                  }
              }
              ctrl.$setValidity('startdate', true);
              return value;
          };
          ctrl.$parsers.unshift(compareStartDates);
      }
  };
  })
  </code></pre>
  
  <p>JSFiddle: <a href="http://jsfiddle.net/2ug4X/" rel="nofollow">http://jsfiddle.net/2ug4X/</a></p>
  
  <p>Look at the fiddle above and do the following:</p>
  
  <p>1) enter "A" in the text box, the pattern error triggers.
  2) click the "CLICK ME" text, which updates teh value of the model on the scope, notice the error clears
  3) enter "1800-01-01" in the text box, the date restriction error triggers
  4) enter "2000-01-01" in the text box which is a valid date, should clear the startdate error but it doesn't.  Any idea why this is happening?</p>
  
  <p>I'd expect updating the ng-model bound variable like so</p>
  
  <pre><code>scope.sample.open_date = '2000-01-01';
  </code></pre>
  
  <p>would clear the error on the input element like the pattern error clears.</p>