@@ -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 always not 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 ) {
@@ -2463,8 +2461,8 @@ var requiredDirective = function() {
2463
2461
if ( ! ctrl ) return ;
2464
2462
attr . required = true ; // force truthy in case we are on non input element
2465
2463
2466
- ctrl . $validators . required = function ( modelValue , viewValue ) {
2467
- return ! attr . required || ! ctrl . $isEmpty ( viewValue ) ;
2464
+ ctrl . $validators . required = function ( value ) {
2465
+ return ! attr . required || ! ctrl . $isEmpty ( value ) ;
2468
2466
} ;
2469
2467
2470
2468
attr . $observe ( 'required' , function ( ) {
@@ -2519,7 +2517,7 @@ var maxlengthDirective = function() {
2519
2517
ctrl . $validate ( ) ;
2520
2518
} ) ;
2521
2519
ctrl . $validators . maxlength = function ( modelValue , viewValue ) {
2522
- return ctrl . $isEmpty ( viewValue ) || viewValue . length <= maxlength ;
2520
+ return ctrl . $isEmpty ( modelValue ) || viewValue . length <= maxlength ;
2523
2521
} ;
2524
2522
}
2525
2523
} ;
@@ -2538,7 +2536,7 @@ var minlengthDirective = function() {
2538
2536
ctrl . $validate ( ) ;
2539
2537
} ) ;
2540
2538
ctrl . $validators . minlength = function ( modelValue , viewValue ) {
2541
- return ctrl . $isEmpty ( viewValue ) || viewValue . length >= minlength ;
2539
+ return ctrl . $isEmpty ( modelValue ) || viewValue . length >= minlength ;
2542
2540
} ;
2543
2541
}
2544
2542
} ;
0 commit comments