@@ -1000,7 +1000,7 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
1000
1000
element . on ( 'change' , listener ) ;
1001
1001
1002
1002
ctrl . $render = function ( ) {
1003
- element . val ( ctrl . $isEmpty ( ctrl . $viewValue ) ? '' : ctrl . $viewValue ) ;
1003
+ element . val ( ctrl . $isEmpty ( ctrl . $modelValue ) ? '' : ctrl . $viewValue ) ;
1004
1004
} ;
1005
1005
}
1006
1006
@@ -1192,8 +1192,7 @@ function urlInputType(scope, element, attr, ctrl, $sniffer, $browser) {
1192
1192
stringBasedInputType ( ctrl ) ;
1193
1193
1194
1194
ctrl . $$parserName = 'url' ;
1195
- ctrl . $validators . url = function ( modelValue , viewValue ) {
1196
- var value = modelValue || viewValue ;
1195
+ ctrl . $validators . url = function ( value ) {
1197
1196
return ctrl . $isEmpty ( value ) || URL_REGEXP . test ( value ) ;
1198
1197
} ;
1199
1198
}
@@ -1205,8 +1204,7 @@ function emailInputType(scope, element, attr, ctrl, $sniffer, $browser) {
1205
1204
stringBasedInputType ( ctrl ) ;
1206
1205
1207
1206
ctrl . $$parserName = 'email' ;
1208
- ctrl . $validators . email = function ( modelValue , viewValue ) {
1209
- var value = modelValue || viewValue ;
1207
+ ctrl . $validators . email = function ( value ) {
1210
1208
return ctrl . $isEmpty ( value ) || EMAIL_REGEXP . test ( value ) ;
1211
1209
} ;
1212
1210
}
@@ -1260,7 +1258,7 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
1260
1258
element [ 0 ] . checked = ctrl . $viewValue ;
1261
1259
} ;
1262
1260
1263
- // Override the standard `$isEmpty` because a value of `false` means empty in a checkbox.
1261
+ // Override the standard `$isEmpty` because an empty checkbox is never equal to the trueValue
1264
1262
ctrl . $isEmpty = function ( value ) {
1265
1263
return value !== trueValue ;
1266
1264
} ;
@@ -1719,7 +1717,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1719
1717
* default. The `checkboxInputType` directive does this because in its case a value of `false`
1720
1718
* implies empty.
1721
1719
*
1722
- * @param {* } value Reference to check.
1720
+ * @param {* } value Model value to check.
1723
1721
* @returns {boolean } True if `value` is empty.
1724
1722
*/
1725
1723
this . $isEmpty = function ( value ) {
@@ -2471,8 +2469,8 @@ var requiredDirective = function() {
2471
2469
if ( ! ctrl ) return ;
2472
2470
attr . required = true ; // force truthy in case we are on non input element
2473
2471
2474
- ctrl . $validators . required = function ( modelValue , viewValue ) {
2475
- return ! attr . required || ! ctrl . $isEmpty ( viewValue ) ;
2472
+ ctrl . $validators . required = function ( value ) {
2473
+ return ! attr . required || ! ctrl . $isEmpty ( value ) ;
2476
2474
} ;
2477
2475
2478
2476
attr . $observe ( 'required' , function ( ) {
@@ -2527,7 +2525,7 @@ var maxlengthDirective = function() {
2527
2525
ctrl . $validate ( ) ;
2528
2526
} ) ;
2529
2527
ctrl . $validators . maxlength = function ( modelValue , viewValue ) {
2530
- return ctrl . $isEmpty ( viewValue ) || viewValue . length <= maxlength ;
2528
+ return ctrl . $isEmpty ( modelValue ) || viewValue . length <= maxlength ;
2531
2529
} ;
2532
2530
}
2533
2531
} ;
@@ -2546,7 +2544,7 @@ var minlengthDirective = function() {
2546
2544
ctrl . $validate ( ) ;
2547
2545
} ) ;
2548
2546
ctrl . $validators . minlength = function ( modelValue , viewValue ) {
2549
- return ctrl . $isEmpty ( viewValue ) || viewValue . length >= minlength ;
2547
+ return ctrl . $isEmpty ( modelValue ) || viewValue . length >= minlength ;
2550
2548
} ;
2551
2549
}
2552
2550
} ;
0 commit comments