@@ -17,7 +17,9 @@ var inputType = {
17
17
* @name input[text]
18
18
*
19
19
* @description
20
- * Standard HTML text input with angular data binding.
20
+ * Standard HTML text input with angular data binding, inherited by most of the `input` elements.
21
+ *
22
+ * *NOTE* Not every feature offered is available for all input types.
21
23
*
22
24
* @param {string } ngModel Assignable angular expression to data-bind to.
23
25
* @param {string= } name Property name of the form under which the control is published.
@@ -35,6 +37,8 @@ var inputType = {
35
37
* @param {string= } ngChange Angular expression to be executed when input changes due to user
36
38
* interaction with the input element.
37
39
* @param {boolean= } [ngTrim=true] If set to false Angular will not automatically trim the input.
40
+ * This parameter is ignored for input[type=password] controls, which will never trim the
41
+ * input.
38
42
*
39
43
* @example
40
44
<example name="text-input-directive" module="textInputExample">
@@ -474,6 +478,7 @@ function addNativeHtml5Validators(ctrl, validatorName, badFlags, ignoreFlags, va
474
478
function textInputType ( scope , element , attr , ctrl , $sniffer , $browser ) {
475
479
var validity = element . prop ( VALIDITY_STATE_PROPERTY ) ;
476
480
var placeholder = element [ 0 ] . placeholder , noevent = { } ;
481
+ var type = element [ 0 ] . type . toLowerCase ( ) ;
477
482
ctrl . $$validityState = validity ;
478
483
479
484
// In composition mode, users are still inputing intermediate text buffer,
@@ -507,8 +512,8 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
507
512
508
513
// By default we will trim the value
509
514
// If the attribute ng-trim exists we will avoid trimming
510
- // e.g. < input ng-model="foo" ng-trim="false">
511
- if ( toBoolean ( attr . ngTrim || 'T' ) ) {
515
+ // If input type is 'password', the value is never trimmed
516
+ if ( type !== 'password' && ( toBoolean ( attr . ngTrim || 'T' ) ) ) {
512
517
value = trim ( value ) ;
513
518
}
514
519
@@ -783,6 +788,8 @@ function checkboxInputType(scope, element, attr, ctrl) {
783
788
* HTML input element control with angular data-binding. Input control follows HTML5 input types
784
789
* and polyfills the HTML5 validation behavior for older browsers.
785
790
*
791
+ * *NOTE* Not every feature offered is available for all input types.
792
+ *
786
793
* @param {string } ngModel Assignable angular expression to data-bind to.
787
794
* @param {string= } name Property name of the form under which the control is published.
788
795
* @param {string= } required Sets `required` validation error key if the value is not entered.
@@ -796,6 +803,9 @@ function checkboxInputType(scope, element, attr, ctrl) {
796
803
* patterns defined as scope expressions.
797
804
* @param {string= } ngChange Angular expression to be executed when input changes due to user
798
805
* interaction with the input element.
806
+ * @param {boolean= } [ngTrim=true] If set to false Angular will not automatically trim the input.
807
+ * This parameter is ignored for input[type=password] controls, which will never trim the
808
+ * input.
799
809
*
800
810
* @example
801
811
<example name="input-directive" module="inputExample">
0 commit comments