diff options
| -rw-r--r-- | src/ng/directive/input.js | 4 | ||||
| -rw-r--r-- | test/ng/directive/inputSpec.js | 23 | 
2 files changed, 26 insertions, 1 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 1d8d14ee..9ff50364 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -1097,7 +1097,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$     * It will update the $viewValue, then pass this value through each of the functions in `$parsers`,     * which includes any validators. The value that comes out of this `$parsers` pipeline, be applied to     * `$modelValue` and the **expression** specified in the `ng-model` attribute. -   *  +   *     * Lastly, all the registered change listeners, in the `$viewChangeListeners` list, are called.     *     * Note that calling this function does not trigger a `$digest`. @@ -1154,6 +1154,8 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$          ctrl.$render();        }      } + +    return value;    });  }]; diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 892c1b7f..c568e807 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -383,6 +383,29 @@ describe('ngModel', function() {        dealoc(element);      });    }); + +  it('should keep previously defined watches consistent when changes in validity are made', +   inject(function($compile, $rootScope) { + +     var isFormValid; +     $rootScope.$watch('myForm.$valid', function(value) { isFormValid = value; }); + +     var element = $compile('<form name="myForm">' + +      '<input  name="myControl" ng-model="value" required >' + +      '</form>')($rootScope); + +     $rootScope.$apply(); +     expect(isFormValid).toBe(false); +     expect($rootScope.myForm.$valid).toBe(false); + +     $rootScope.value='value'; +     $rootScope.$apply(); +     expect(isFormValid).toBe(true); +     expect($rootScope.myForm.$valid).toBe(true); + +     dealoc(element); +   })); +  });  | 
