title: Angularjs setValidity causing modelValue to not update
body: <p>I'm having some basic trouble with a form. Here's what I did. </p>
  
  <p>I snagged this cool looking directive from here: <a href="https://github.com/TheSharpieOne/angular-input-match" rel="nofollow">https://github.com/TheSharpieOne/angular-input-match</a></p>
  
  <p>It looks like this:</p>
  
  <pre><code>directive('match', function () {
      return {
        require: 'ngModel',
        restrict: 'A',
        scope: {
          match: '='
        },
        link: function(scope, elem, attrs, ngModel) {
          scope.$watch(function() {
            return (ngModel.$pristine &amp;&amp; angular.isUndefined(ngModel.$modelValue)) || scope.match === ngModel.$viewValue;
          }, function(currentValue, previousValue) {
            ngModel.$setValidity('match', currentValue);
          });
        }
      };
    });
  </code></pre>
  
  <p>Essentially, this directive watches the element it is attached to's model value, and compares it to the model value in the match attribute. </p>
  
  <p>So...for example, below we're watching to see if both passwords match:</p>
  
  <pre><code>Password: &lt;input ng-model="password" type="password" /&gt;
  Confirm: &lt;input ng-model="passwordConfirm" type="password" match="password" /&gt;
  </code></pre>
  
  <p>The directive seems to be working, in that it sets ng-valid-match and ng-invalid-match appropriately. </p>
  
  <p>However, once it is set to invalid, the passwordConfirm model never gets updated again. I've done a ton of console.loggin, looking at ngModel in the directive, and here is what it looks like when both passwords match:</p>
  
  <pre><code>Constructor {$viewValue: "asdf", $modelValue: undefined, $validators: Object, $parsers: Array[0], $formatters: Array[0]…}
  $$debounceViewValueCommit: function (trigger, revalidate) {
  $$invalidModelValue: "asdf"
  $$lastCommittedViewValue: "asdf"
  $$runValidators: function (modelValue, viewValue) {
  $$validityState: ValidityState
  $$writeModelToScope: function () {
  $commitViewValue: function (revalidate) {
  $dirty: true
  $error: Object
  $formatters: Array[0]
  $invalid: false
  $isEmpty: function (value) {
  $modelValue: undefined
  $name: "passwordConfirmation"
  $parsers: Array[0]
  $pristine: false
  $render: function () {
  $rollbackViewValue: function () {
  $setPristine: function () {
  $setTouched: function () {
  $setUntouched: function () {
  $setValidity: function (validationErrorKey, isValid) {
  $setViewValue: function (value, trigger, revalidate) {
  $touched: true
  $untouched: false
  $valid: true
  $validate: function () {
  $validators: Object
  $viewChangeListeners: Array[0]
  $viewValue: "asdf"
  __proto__: Object
  </code></pre>
  
  <p>Note that the $viewValue is correct, but the $modelValue is listed as undefined and $invalidModelValue still has a value. </p>
  
  <p>Here's what the html looks like, again when both passwords match:</p>
  
  <pre><code>&lt;input type="password" class="form-control ng-isolate-scope ng-dirty ng-valid-required ng-valid ng-valid-match ng-touched" id="passwordConfirmation" name="passwordConfirmation" placeholder="Confirm your password" ng-model="passwordConfirmation" required="" match="password" style=""&gt;
  </code></pre>
  
  <p>Am I missing something somewhere? I've been running in circles for hours.</p>