/
textfield.component.html
278 lines (229 loc) · 6.47 KB
/
textfield.component.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<h4>Text Fields</h4>
<mdl-textfield
#theFirstTextfield
type="text"
label="Text..."
[(ngModel)]="text1"
placeholder="type a text"
autofocus
autocomplete="name"
(blur)="onBlur($event)"
(focus)="onFocus($event)"></mdl-textfield>
<mdl-textfield
type="text"
label="Number..."
pattern="-?[0-9]*(\.[0-9]+)?"
error-msg="Input is not a number!"
[(ngModel)]="text2"></mdl-textfield>
<br/>
{{text1}}
{{text2}}
<br/>
<mdl-textfield type="text" label="Text...(disabled)" [(ngModel)]="text3" disabled></mdl-textfield>
<br/>
<mdl-textfield type="text" label="Text...(required)" [(ngModel)]="text3" required=""></mdl-textfield>
<pre prism>
<![CDATA[
<mdl-textfield
type="text"
label="Text..."
[(ngModel)]="text1"
placeholder="type a text"
autofocus
autocomplete="name"
(blur)="onBlur($event)"
(focus)="onFocus($event)"></mdl-textfield>
<mdl-textfield
type="text"
label="Number..."
pattern="-?[0-9]*(\.[0-9]+)?"
error-msg="Input is not a number!"
[(ngModel)]="text2"></mdl-textfield>
]]>
</pre>
<h5>Set max length</h5>
<mdl-textfield type="text" label="maxlength is 10" maxlength="10"></mdl-textfield>
<pre prism>
<![CDATA[
<mdl-textfield type="text" label="maxlength is 10" maxlength="10"></mdl-textfield>
]]>
</pre>
<h5>Text/Numeric with floating label</h5>
<mdl-textfield name="text1" type="text" label="Text..." [(ngModel)]="text3" floating-label></mdl-textfield>
<mdl-textfield
name="text2"
type="text"
label="Number..."
pattern="-?[0-9]*(\.[0-9]+)?"
error-msg="Input is not a number!"
[(ngModel)]="text4"
floating-label ></mdl-textfield>
<br/>
{{text3}}
{{text4}}
<pre prism>
<![CDATA[
<mdl-textfield type="text" label="Text..." [(ngModel)]="text3" floating-label></mdl-textfield>
<mdl-textfield
type="text"
label="Number..."
pattern="-?[0-9]*(\.[0-9]+)?"
error-msg="Input is not a number!"
[(ngModel)]="text4"
floating-label ></mdl-textfield>
]]>
</pre>
<h5>Number with min and step restrictions</h5>
<mdl-textfield
name="number1"
type="number"
label="Number..."
min="0"
step="0.01"
error-msg="invalid number!"
[(ngModel)]="number1"
floating-label ></mdl-textfield>
<br/>
{{number1}}
{{valueType}}
<pre prism>
<![CDATA[
<mdl-textfield
name="number1"
type="number"
label="Number..."
min="0"
step="0.01"
error-msg="Input is not a number!"
[(ngModel)]="number1"
floating-label ></mdl-textfield>
]]>
</pre>
<h5>Multiline Textfield</h5>
aka Textarea. Add the attribute row to turn the input field to a textarea. Specify maxrows to restrict the
possible lines.<br/>
<mdl-textfield label="Text..." [(ngModel)]="text5" rows="3" maxrows="3" floating-label></mdl-textfield>
<br/>
{{text5}}
<pre prism>
<![CDATA[
<mdl-textfield label="Text..." [(ngModel)]="text5" rows="3" maxrows="3" floating-label></mdl-textfield>
]]>
</pre>
<h5>Expandable</h5>
Just specify an icon to turn the text input field into an expandable field.
<br/>
<mdl-textfield type="text" [(ngModel)]="text6" icon="search"></mdl-textfield>
<br/>
{{text6}}
<pre prism>
<![CDATA[
<mdl-textfield type="text" [(ngModel)]="text6" icon="search"></mdl-textfield>
]]>
</pre>
<h5>Attributes of the mdl-textfield component</h5>
<table class="docu" mdl-shadow="2">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>autofocus</td>
<td>Set the focus on this input field on page load.</td>
</tr>
<tr>
<td>disableNativeValidityChecking</td>
<td>Is a BooleanProperty that disables the build in native checking to mark the input
field as invalid.
See <a href="https://github.com/mseemann/angular2-mdl/wiki/Mdl-Textfield-and-native-validity-checking"
target="_blank">
https://github.com/mseemann/angular2-mdl/wiki/Mdl-Textfield-and-native-validity-checking
</a>for a detailed description.
</td>
</tr>
<tr>
<td>disabled</td>
<td>Disable the text field if present or true.</td>
</tr>
<tr>
<td>error-msg</td>
<td>The error message that will be shown if the input value did not match the pattern.</td>
</tr>
<tr>
<td>floating-label</td>
<td>If present or true the label of the text field will be floating if the element has the focus.</td>
</tr>
<tr>
<td>icon</td>
<td>If present the input field is hidden until the icon is clicked or the
component gains the focus. The icon must be a material design icon.</td>
</tr>
<tr>
<td>label</td>
<td>The label of the input field</td>
</tr>
<tr>
<td>max</td>
<td>Restrict the value for type number to a max value.</td>
</tr>
<tr>
<td>maxrows</td>
<td>Defines the maximum number of row the component will expand to.</td>
</tr>
<tr>
<td>min</td>
<td>Restrict the value for type number to a min value.</td>
</tr>
<tr>
<td>step</td>
<td>Restrict the value for type number to a be based on the given step (e.g. 0.01
for numbers with two decimal places).</td>
</tr>
<tr>
<td>ngModel</td>
<td>The text field is ngModel compatible.</td>
</tr>
<tr>
<td>pattern</td>
<td>A regular expression that the input text must conform to. If it dosen't match
the error (attribute <i>error-msg</i>) will be shown</td>
</tr>
<tr>
<td>placeholder</td>
<td>A placeholder string for the input filed.</td>
</tr>
<tr>
<td>readonly</td>
<td>Mark the text field as readonly.</td>
</tr>
<tr>
<td>required</td>
<td>Mark the text field as required.</td>
</tr>
<tr>
<td>rows</td>
<td>If present the input field will be drawn as textarea. You can specify the number of rows.</td>
</tr>
<tr>
<td>type</td>
<td>
The type of the input field - propaget to the underlying <i>input</i> element.
</td>
</tr>
<tr>
<td>maxlength</td>
<td>The max. length for the input field.</td>
</tr>
<tr>
<td>(blur)</td>
<td>The event fires if the input element is loosing the focus.</td>
</tr>
<tr>
<td>(focus)</td>
<td>The event fires if the input element is getting the focus.</td>
</tr>
</tbody>
</table>