@@ -25,7 +25,9 @@ var inputType = {
25
25
* @name input[text]
26
26
*
27
27
* @description
28
- * Standard HTML text input with angular data binding.
28
+ * Standard HTML text input with angular data binding, inherited by most of the `input` elements.
29
+ *
30
+ * *NOTE* Not every feature offered is available for all input types.
29
31
*
30
32
* @param {string } ngModel Assignable angular expression to data-bind to.
31
33
* @param {string= } name Property name of the form under which the control is published.
@@ -43,6 +45,8 @@ var inputType = {
43
45
* @param {string= } ngChange Angular expression to be executed when input changes due to user
44
46
* interaction with the input element.
45
47
* @param {boolean= } [ngTrim=true] If set to false Angular will not automatically trim the input.
48
+ * This parameter is ignored for input[type=password] controls, which will never trim the
49
+ * input.
46
50
*
47
51
* @example
48
52
<example name="text-input-directive" module="textInputExample">
@@ -908,6 +912,7 @@ function addNativeHtml5Validators(ctrl, validatorName, badFlags, ignoreFlags, va
908
912
function textInputType ( scope , element , attr , ctrl , $sniffer , $browser ) {
909
913
var validity = element . prop ( VALIDITY_STATE_PROPERTY ) ;
910
914
var placeholder = element [ 0 ] . placeholder , noevent = { } ;
915
+ var type = element [ 0 ] . type . toLowerCase ( ) ;
911
916
ctrl . $$validityState = validity ;
912
917
913
918
// In composition mode, users are still inputing intermediate text buffer,
@@ -942,8 +947,8 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
942
947
943
948
// By default we will trim the value
944
949
// If the attribute ng-trim exists we will avoid trimming
945
- // e.g. < input ng-model="foo" ng-trim="false">
946
- if ( ! attr . ngTrim || attr . ngTrim !== 'false' ) {
950
+ // If input type is 'password', the value is never trimmed
951
+ if ( type !== 'password' && ( ! attr . ngTrim || attr . ngTrim !== 'false' ) ) {
947
952
value = trim ( value ) ;
948
953
}
949
954
@@ -1276,6 +1281,8 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
1276
1281
* HTML input element control with angular data-binding. Input control follows HTML5 input types
1277
1282
* and polyfills the HTML5 validation behavior for older browsers.
1278
1283
*
1284
+ * *NOTE* Not every feature offered is available for all input types.
1285
+ *
1279
1286
* @param {string } ngModel Assignable angular expression to data-bind to.
1280
1287
* @param {string= } name Property name of the form under which the control is published.
1281
1288
* @param {string= } required Sets `required` validation error key if the value is not entered.
@@ -1289,6 +1296,9 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
1289
1296
* patterns defined as scope expressions.
1290
1297
* @param {string= } ngChange Angular expression to be executed when input changes due to user
1291
1298
* interaction with the input element.
1299
+ * @param {boolean= } [ngTrim=true] If set to false Angular will not automatically trim the input.
1300
+ * This parameter is ignored for input[type=password] controls, which will never trim the
1301
+ * input.
1292
1302
*
1293
1303
* @example
1294
1304
<example name="input-directive" module="inputExample">
0 commit comments