@@ -1763,8 +1763,11 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1763
1763
* Runs each of the registered validations set on the $validators object.
1764
1764
*/
1765
1765
this . $validate = function ( modelValue , viewValue ) {
1766
- modelValue = modelValue || ctrl . $modelValue ;
1767
- viewValue = viewValue || ctrl . $viewValue ;
1766
+ if ( arguments . length === 0 ) {
1767
+ modelValue = ctrl . $modelValue ;
1768
+ viewValue = ctrl . $viewValue ;
1769
+ }
1770
+
1768
1771
forEach ( ctrl . $validators , function ( fn , name ) {
1769
1772
ctrl . $setValidity ( name , fn ( modelValue , viewValue ) ) ;
1770
1773
} ) ;
@@ -1803,11 +1806,12 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1803
1806
modelValue = fn ( modelValue ) ;
1804
1807
} ) ;
1805
1808
1806
- if ( ctrl . $modelValue !== modelValue && ( ! ctrl . $rawModelValue || ctrl . $rawModelValue != modelValue ) ) {
1809
+ if ( ctrl . $modelValue !== modelValue &&
1810
+ ( isUndefined ( ctrl . $$invalidModelValue ) || ctrl . $$invalidModelValue != modelValue ) ) {
1807
1811
1808
1812
ctrl . $validate ( modelValue , viewValue ) ;
1809
- ctrl . $modelValue = ctrl . $valid ? modelValue : undefined ;
1810
- ctrl . $rawModelValue = ctrl . $valid ? undefined : modelValue ;
1813
+ ctrl . $modelValue = ctrl . $valid ? modelValue : undefined ;
1814
+ ctrl . $$invalidModelValue = ctrl . $valid ? undefined : modelValue ;
1811
1815
1812
1816
ngModelSet ( $scope , ctrl . $modelValue ) ;
1813
1817
forEach ( ctrl . $viewChangeListeners , function ( listener ) {
@@ -1886,7 +1890,8 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1886
1890
var modelValue = ngModelGet ( $scope ) ;
1887
1891
1888
1892
// if scope model value and ngModel value are out of sync
1889
- if ( ctrl . $modelValue !== modelValue && ( ! ctrl . $rawModelValue || ctrl . $rawModelValue != modelValue ) ) {
1893
+ if ( ctrl . $modelValue !== modelValue &&
1894
+ ( isUndefined ( ctrl . $$invalidModelValue ) || ctrl . $$invalidModelValue != modelValue ) ) {
1890
1895
1891
1896
var formatters = ctrl . $formatters ,
1892
1897
idx = formatters . length ;
@@ -1897,8 +1902,8 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1897
1902
}
1898
1903
1899
1904
ctrl . $validate ( modelValue , viewValue ) ;
1900
- ctrl . $modelValue = ctrl . $valid ? modelValue : undefined ;
1901
- ctrl . $rawModelValue = ctrl . $valid ? undefined : modelValue ;
1905
+ ctrl . $modelValue = ctrl . $valid ? modelValue : undefined ;
1906
+ ctrl . $$invalidModelValue = ctrl . $valid ? undefined : modelValue ;
1902
1907
1903
1908
if ( ctrl . $viewValue !== viewValue ) {
1904
1909
ctrl . $viewValue = ctrl . $$lastCommittedViewValue = viewValue ;
0 commit comments