|
6 | 6 | <mat-card>
|
7 | 7 | <mat-card-subtitle>ngModel</mat-card-subtitle>
|
8 | 8 |
|
9 |
| - <mat-card-content> |
10 |
| - <mat-form-field [floatLabel]="floatLabel" [color]="drinksTheme" |
11 |
| - [class.demo-drinks-width-large]="drinksWidth === '400px'"> |
12 |
| - <mat-label>Drink</mat-label> |
13 |
| - <mat-select [(ngModel)]="currentDrink" [required]="drinksRequired" |
14 |
| - [disabled]="drinksDisabled" #drinkControl="ngModel"> |
15 |
| - <mat-option>None</mat-option> |
16 |
| - <mat-option *ngFor="let drink of drinks" [value]="drink.value" [disabled]="drink.disabled"> |
17 |
| - {{ drink.viewValue }} |
18 |
| - </mat-option> |
19 |
| - </mat-select> |
20 |
| - <mat-icon matPrefix class="demo-drink-icon">local_drink</mat-icon> |
21 |
| - <mat-hint>Pick a drink!</mat-hint> |
22 |
| - <mat-error>You must make a selection</mat-error> |
23 |
| - </mat-form-field> |
24 |
| - <p> Value: {{ currentDrink }} </p> |
25 |
| - <p> Touched: {{ drinkControl.touched }} </p> |
26 |
| - <p> Dirty: {{ drinkControl.dirty }} </p> |
27 |
| - <p> Status: {{ drinkControl.control?.status }} </p> |
28 |
| - <p> |
29 |
| - <label for="floating-label">Floating label:</label> |
30 |
| - <select [(ngModel)]="floatLabel" id="floating-label"> |
31 |
| - <option value="auto">Auto</option> |
32 |
| - <option value="always">Always</option> |
33 |
| - <option value="never">Never</option> |
34 |
| - </select> |
35 |
| - </p> |
36 |
| - <p> |
37 |
| - <label for="drinks-width">Width:</label> |
38 |
| - <select [(ngModel)]="drinksWidth" id="drinks-width"> |
39 |
| - <option value="default">Default</option> |
40 |
| - <option value="400px">400px</option> |
41 |
| - </select> |
42 |
| - </p> |
43 |
| - <p> |
44 |
| - <label for="drinks-theme">Theme:</label> |
45 |
| - <select [(ngModel)]="drinksTheme" id="drinks-theme"> |
46 |
| - <option *ngFor="let theme of availableThemes" [value]="theme.value"> |
47 |
| - {{theme.name}} |
48 |
| - </option> |
49 |
| - </select> |
50 |
| - </p> |
| 9 | + <mat-form-field [floatLabel]="floatLabel" [color]="drinksTheme" |
| 10 | + [class.demo-drinks-width-large]="drinksWidth === '400px'"> |
| 11 | + <mat-label>Drink</mat-label> |
| 12 | + <mat-select [(ngModel)]="currentDrink" [required]="drinksRequired" |
| 13 | + [disabled]="drinksDisabled" #drinkControl="ngModel"> |
| 14 | + <mat-option>None</mat-option> |
| 15 | + <mat-option *ngFor="let drink of drinks" [value]="drink.value" [disabled]="drink.disabled"> |
| 16 | + {{ drink.viewValue }} |
| 17 | + </mat-option> |
| 18 | + </mat-select> |
| 19 | + <mat-icon matPrefix class="demo-drink-icon">local_drink</mat-icon> |
| 20 | + <mat-hint>Pick a drink!</mat-hint> |
| 21 | + <mat-error>You must make a selection</mat-error> |
| 22 | + </mat-form-field> |
| 23 | + <p> Value: {{ currentDrink }} </p> |
| 24 | + <p> Touched: {{ drinkControl.touched }} </p> |
| 25 | + <p> Dirty: {{ drinkControl.dirty }} </p> |
| 26 | + <p> Status: {{ drinkControl.control?.status }} </p> |
| 27 | + <p> |
| 28 | + <label for="floating-placeholder">Floating placeholder:</label> |
| 29 | + <select [(ngModel)]="floatLabel" id="floating-placeholder"> |
| 30 | + <option value="auto">Auto</option> |
| 31 | + <option value="always">Always</option> |
| 32 | + <option value="never">Never</option> |
| 33 | + </select> |
| 34 | + </p> |
| 35 | + <p> |
| 36 | + <label for="drinks-width">Width:</label> |
| 37 | + <select [(ngModel)]="drinksWidth" id="drinks-width"> |
| 38 | + <option value="default">Default</option> |
| 39 | + <option value="400px">400px</option> |
| 40 | + </select> |
| 41 | + </p> |
| 42 | + <p> |
| 43 | + <label for="drinks-theme">Theme:</label> |
| 44 | + <select [(ngModel)]="drinksTheme" id="drinks-theme"> |
| 45 | + <option *ngFor="let theme of availableThemes" [value]="theme.value"> |
| 46 | + {{theme.name}} |
| 47 | + </option> |
| 48 | + </select> |
| 49 | + </p> |
51 | 50 |
|
52 |
| - <button mat-button (click)="currentDrink='water-2'">SET VALUE</button> |
53 |
| - <button mat-button (click)="drinksRequired=!drinksRequired">TOGGLE REQUIRED</button> |
54 |
| - <button mat-button (click)="drinksDisabled=!drinksDisabled">TOGGLE DISABLED</button> |
55 |
| - <button mat-button (click)="drinkControl.reset()">RESET</button> |
56 |
| - </mat-card-content> |
| 51 | + <button mat-button (click)="currentDrink='water-2'">SET VALUE</button> |
| 52 | + <button mat-button (click)="drinksRequired=!drinksRequired">TOGGLE REQUIRED</button> |
| 53 | + <button mat-button (click)="drinksDisabled=!drinksDisabled">TOGGLE DISABLED</button> |
| 54 | + <button mat-button (click)="drinkControl.reset()">RESET</button> |
57 | 55 | </mat-card>
|
58 | 56 |
|
59 | 57 | <mat-card>
|
|
89 | 87 | <mat-card>
|
90 | 88 | <mat-card-subtitle>Without Angular forms</mat-card-subtitle>
|
91 | 89 |
|
92 |
| - <mat-card-content> |
93 |
| - <mat-form-field> |
94 |
| - <mat-label>Digimon</mat-label> |
95 |
| - <mat-select [(value)]="currentDigimon"> |
96 |
| - <mat-option>None</mat-option> |
97 |
| - <mat-option *ngFor="let creature of digimon" [value]="creature.value"> |
98 |
| - {{ creature.viewValue }} |
99 |
| - </mat-option> |
100 |
| - </mat-select> |
101 |
| - </mat-form-field> |
| 90 | + <mat-form-field> |
| 91 | + <mat-label>Digimon</mat-label> |
| 92 | + <mat-select [(value)]="currentDigimon"> |
| 93 | + <mat-option>None</mat-option> |
| 94 | + <mat-option *ngFor="let creature of digimon" [value]="creature.value"> |
| 95 | + {{ creature.viewValue }} |
| 96 | + </mat-option> |
| 97 | + </mat-select> |
| 98 | + </mat-form-field> |
102 | 99 |
|
103 |
| - <p>Value: {{ currentDigimon }}</p> |
| 100 | + <p>Value: {{ currentDigimon }}</p> |
104 | 101 |
|
105 |
| - <button mat-button (click)="currentDigimon='pajiramon-3'">SET VALUE</button> |
106 |
| - <button mat-button (click)="currentDigimon=''">RESET</button> |
107 |
| - </mat-card-content> |
| 102 | + <button mat-button (click)="currentDigimon='pajiramon-3'">SET VALUE</button> |
| 103 | + <button mat-button (click)="currentDigimon=''">RESET</button> |
108 | 104 | </mat-card>
|
109 | 105 |
|
110 | 106 | <mat-card>
|
|
159 | 155 | <mat-card>
|
160 | 156 | <mat-card-subtitle>Appearance comparison</mat-card-subtitle>
|
161 | 157 | <mat-card-content>
|
| 158 | + <p> |
| 159 | + <mat-form-field> |
| 160 | + <mat-label>Legacy</mat-label> |
| 161 | + <mat-select [(value)]="currentAppearanceValue"> |
| 162 | + <mat-option>None</mat-option> |
| 163 | + <mat-option *ngFor="let creature of digimon" [value]="creature.value"> |
| 164 | + {{ creature.viewValue }} |
| 165 | + </mat-option> |
| 166 | + </mat-select> |
| 167 | + </mat-form-field> |
| 168 | + </p> |
| 169 | + |
| 170 | + <p> |
| 171 | + <mat-form-field appearance="standard"> |
| 172 | + <mat-label>Standard</mat-label> |
| 173 | + <mat-select [(value)]="currentAppearanceValue"> |
| 174 | + <mat-option>None</mat-option> |
| 175 | + <mat-option *ngFor="let creature of digimon" [value]="creature.value"> |
| 176 | + {{ creature.viewValue }} |
| 177 | + </mat-option> |
| 178 | + </mat-select> |
| 179 | + </mat-form-field> |
| 180 | + </p> |
| 181 | + |
162 | 182 | <p>
|
163 | 183 | <mat-form-field appearance="fill">
|
164 | 184 | <mat-label>Fill</mat-label>
|
|
226 | 246 | </mat-card>
|
227 | 247 | </div>
|
228 | 248 |
|
| 249 | + <mat-card> |
| 250 | + <mat-card-subtitle>MatSelect inside a dialog</mat-card-subtitle> |
| 251 | + <mat-card-content> |
| 252 | + |
| 253 | + <button (click)="openDialogWithSelectInside(dialogTemplate)">Open dialog</button> |
| 254 | + |
| 255 | + <ng-template #dialogTemplate> |
| 256 | + <mat-form-field> |
| 257 | + <mat-label>Your name</mat-label> |
| 258 | + <input matInput> |
| 259 | + </mat-form-field> |
| 260 | + |
| 261 | + <mat-form-field> |
| 262 | + <mat-label>Select a topping</mat-label> |
| 263 | + <mat-select> |
| 264 | + <mat-option value="cheese">Cheese</mat-option> |
| 265 | + <mat-option value="onion">Onion</mat-option> |
| 266 | + <mat-option value="pepper">Pepper</mat-option> |
| 267 | + </mat-select> |
| 268 | + </mat-form-field> |
| 269 | + |
| 270 | + <button>Done</button> |
| 271 | + </ng-template> |
| 272 | + |
| 273 | + </mat-card-content> |
| 274 | + </mat-card> |
| 275 | + |
229 | 276 | </div>
|
230 | 277 |
|
231 | 278 | <mat-card class="demo-card demo-basic">
|
@@ -290,6 +337,24 @@ <h4>Floating label</h4>
|
290 | 337 | </select>
|
291 | 338 | </mat-form-field>
|
292 | 339 | <h4>Looks</h4>
|
| 340 | + <mat-form-field appearance="legacy"> |
| 341 | + <mat-label>Legacy</mat-label> |
| 342 | + <select matNativeControl required> |
| 343 | + <option value="volvo">Volvo</option> |
| 344 | + <option value="saab">Saab</option> |
| 345 | + <option value="mercedes">Mercedes</option> |
| 346 | + <option value="audi">Audi</option> |
| 347 | + </select> |
| 348 | + </mat-form-field> |
| 349 | + <mat-form-field appearance="standard"> |
| 350 | + <mat-label>Standard</mat-label> |
| 351 | + <select matNativeControl required> |
| 352 | + <option value="volvo">Volvo</option> |
| 353 | + <option value="saab">Saab</option> |
| 354 | + <option value="mercedes">Mercedes</option> |
| 355 | + <option value="audi">Audi</option> |
| 356 | + </select> |
| 357 | + </mat-form-field> |
293 | 358 | <mat-form-field appearance="fill">
|
294 | 359 | <mat-label>Fill</mat-label>
|
295 | 360 | <select matNativeControl required>
|
@@ -323,6 +388,16 @@ <h4>Option group</h4>
|
323 | 388 | </optgroup>
|
324 | 389 | </select>
|
325 | 390 | </mat-form-field>
|
| 391 | + <h4>Place holder</h4> |
| 392 | + <mat-form-field class="demo-full-width"> |
| 393 | + <select matNativeControl placeholder="place holder"> |
| 394 | + <option value="" disabled selected></option> |
| 395 | + <option value="volvo">Volvo</option> |
| 396 | + <option value="saab" disabled>Saab</option> |
| 397 | + <option value="mercedes">Mercedes</option> |
| 398 | + <option value="audi">Audi</option> |
| 399 | + </select> |
| 400 | + </mat-form-field> |
326 | 401 | <h4>Error message, hint, form sumbit</h4>
|
327 | 402 | <mat-form-field class="demo-full-width">
|
328 | 403 | <mat-label>Select your car (required)</mat-label>
|
|
0 commit comments