@@ -34,7 +34,13 @@ import { Debouncer } from '../../util/debouncer';
34
34
'<ion-icon name="arrow-back"></ion-icon>' +
35
35
'</button>' +
36
36
'<div #searchbarIcon class="searchbar-search-icon"></div>' +
37
- '<input #searchbarInput [(ngModel)]="_value" [attr.placeholder]="placeholder" (input)="inputChanged($event)" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" class="searchbar-input">' +
37
+ '<input #searchbarInput [(ngModel)]="_value" ' +
38
+ '[attr.placeholder]="placeholder" ' +
39
+ '[attr.type]="type" ' +
40
+ '[attr.autocomplete]="_autocomplete" ' +
41
+ '[attr.autocorrect]="_autocorrect" ' +
42
+ '[attr.spellcheck]="_spellcheck" ' +
43
+ '(input)="inputChanged($event)" (blur)="inputBlurred($event)" (focus)="inputFocused($event)" class="searchbar-input">' +
38
44
'<button ion-button clear class="searchbar-clear-icon" (click)="clearInput($event)" (mousedown)="clearInput($event)" type="button"></button>' +
39
45
'</div>' +
40
46
'<button ion-button #cancelButton [tabindex]="_isActive ? 1 : -1" clear (click)="cancelSearchbar($event)" (mousedown)="cancelSearchbar($event)" class="searchbar-ios-cancel" type="button">{{cancelButtonText}}</button>' ,
@@ -52,8 +58,10 @@ export class Searchbar extends Ion {
52
58
_shouldBlur : boolean = true ;
53
59
_shouldAlignLeft : boolean = true ;
54
60
_isCancelVisible : boolean = false ;
61
+ _spellcheck : boolean = false ;
62
+ _autocomplete : string = 'off' ;
63
+ _autocorrect : string = 'off' ;
55
64
_isActive : boolean = false ;
56
- _searchbarInput : ElementRef ;
57
65
_debouncer : Debouncer = new Debouncer ( 250 ) ;
58
66
59
67
/**
@@ -101,17 +109,26 @@ export class Searchbar extends Ion {
101
109
/**
102
110
* @input {string} Set the input's autocomplete property. Values: `"on"`, `"off"`. Default `"off"`.
103
111
*/
104
- @Input ( ) autocomplete : string ;
112
+ @Input ( )
113
+ set autocomplete ( val : string ) {
114
+ this . _autocomplete = ( val === '' || val === 'on' ) ? 'on' : this . _config . get ( 'autocomplete' , 'off' ) ;
115
+ }
105
116
106
117
/**
107
118
* @input {string} Set the input's autocorrect property. Values: `"on"`, `"off"`. Default `"off"`.
108
119
*/
109
- @Input ( ) autocorrect : string ;
120
+ @Input ( )
121
+ set autocorrect ( val : string ) {
122
+ this . _autocorrect = ( val === '' || val === 'on' ) ? 'on' : this . _config . get ( 'autocorrect' , 'off' ) ;
123
+ }
110
124
111
125
/**
112
126
* @input {string|boolean} Set the input's spellcheck property. Values: `true`, `false`. Default `false`.
113
127
*/
114
- @Input ( ) spellcheck : string | boolean ;
128
+ @Input ( )
129
+ set spellcheck ( val : string | boolean ) {
130
+ this . _spellcheck = ( val === '' || val === 'true' || val === true ) ? true : this . _config . getBoolean ( 'spellcheck' , false ) ;
131
+ }
115
132
116
133
/**
117
134
* @input {string} Set the type of the input. Values: `"text"`, `"password"`, `"email"`, `"number"`, `"search"`, `"tel"`, `"url"`. Default `"search"`.
@@ -169,30 +186,7 @@ export class Searchbar extends Ion {
169
186
}
170
187
}
171
188
172
- /**
173
- * @private
174
- */
175
- @ViewChild ( 'searchbarInput' )
176
- set searchbarInput ( searchbarInput : ElementRef ) {
177
- this . _searchbarInput = searchbarInput ;
178
-
179
- let inputEle = searchbarInput . nativeElement ;
180
-
181
- // By defalt set autocomplete="off" unless specified by the input
182
- let autoComplete = ( this . autocomplete === '' || this . autocomplete === 'on' ) ? 'on' : this . _config . get ( 'autocomplete' , 'off' ) ;
183
- inputEle . setAttribute ( 'autocomplete' , autoComplete ) ;
184
-
185
- // by default set autocorrect="off" unless specified by the input
186
- let autoCorrect = ( this . autocorrect === '' || this . autocorrect === 'on' ) ? 'on' : this . _config . get ( 'autocorrect' , 'off' ) ;
187
- inputEle . setAttribute ( 'autocorrect' , autoCorrect ) ;
188
-
189
- // by default set spellcheck="false" unless specified by the input
190
- let spellCheck = ( this . spellcheck === '' || this . spellcheck === 'true' || this . spellcheck === true ) ? true : this . _config . getBoolean ( 'spellcheck' , false ) ;
191
- inputEle . setAttribute ( 'spellcheck' , spellCheck ) ;
192
-
193
- // by default set type="search" unless specified by the input
194
- inputEle . setAttribute ( 'type' , this . type ) ;
195
- }
189
+ @ViewChild ( 'searchbarInput' ) _searchbarInput : ElementRef ;
196
190
197
191
@ViewChild ( 'searchbarIcon' ) _searchbarIcon : ElementRef ;
198
192
0 commit comments