|
6 | 6 | <md-card>
|
7 | 7 | <md-card-subtitle>ngModel</md-card-subtitle>
|
8 | 8 |
|
9 |
| - <md-select placeholder="Drink" [color]="drinksTheme" [(ngModel)]="currentDrink" [required]="drinksRequired" |
10 |
| - [disabled]="drinksDisabled" [floatPlaceholder]="floatPlaceholder" #drinkControl="ngModel"> |
11 |
| - <md-option>None</md-option> |
12 |
| - <md-option *ngFor="let drink of drinks" [value]="drink.value" [disabled]="drink.disabled"> |
13 |
| - {{ drink.viewValue }} |
14 |
| - </md-option> |
15 |
| - </md-select> |
| 9 | + <md-form-field [floatPlaceholder]="floatPlaceholder" [color]="drinksTheme"> |
| 10 | + <md-select placeholder="Drink" [(ngModel)]="currentDrink" [required]="drinksRequired" |
| 11 | + [disabled]="drinksDisabled" #drinkControl="ngModel"> |
| 12 | + <md-option>None</md-option> |
| 13 | + <md-option *ngFor="let drink of drinks" [value]="drink.value" [disabled]="drink.disabled"> |
| 14 | + {{ drink.viewValue }} |
| 15 | + </md-option> |
| 16 | + </md-select> |
| 17 | + <md-icon mdPrefix class="demo-drink-icon">local_drink</md-icon> |
| 18 | + <md-hint>Pick a drink!</md-hint> |
| 19 | + <md-error>You must make a selection</md-error> |
| 20 | + </md-form-field> |
16 | 21 | <p> Value: {{ currentDrink }} </p>
|
17 | 22 | <p> Touched: {{ drinkControl.touched }} </p>
|
18 | 23 | <p> Dirty: {{ drinkControl.dirty }} </p>
|
|
28 | 33 | <p>
|
29 | 34 | <label for="drinks-theme">Theme:</label>
|
30 | 35 | <select [(ngModel)]="drinksTheme" id="drinks-theme">
|
31 |
| - <option *ngFor="let theme of availableThemes" [value]="theme.value">{{ theme.name }}</option> |
| 36 | + <option *ngFor="let theme of availableThemes" [value]="theme.value"> |
| 37 | + {{theme.name}} |
| 38 | + </option> |
32 | 39 | </select>
|
33 | 40 | </p>
|
34 | 41 |
|
|
42 | 49 | <md-card-subtitle>Multiple selection</md-card-subtitle>
|
43 | 50 |
|
44 | 51 | <md-card-content>
|
45 |
| - <md-select multiple [color]="pokemonTheme" placeholder="Pokemon" [(ngModel)]="currentPokemon" |
46 |
| - [required]="pokemonRequired" [disabled]="pokemonDisabled" #pokemonControl="ngModel"> |
47 |
| - <md-option *ngFor="let creature of pokemon" [value]="creature.value"> |
48 |
| - {{ creature.viewValue }} |
49 |
| - </md-option> |
50 |
| - </md-select> |
| 52 | + <md-form-field [color]="pokemonTheme"> |
| 53 | + <md-select multiple placeholder="Pokemon" [(ngModel)]="currentPokemon" |
| 54 | + [required]="pokemonRequired" [disabled]="pokemonDisabled" #pokemonControl="ngModel"> |
| 55 | + <md-option *ngFor="let creature of pokemon" [value]="creature.value"> |
| 56 | + {{ creature.viewValue }} |
| 57 | + </md-option> |
| 58 | + </md-select> |
| 59 | + </md-form-field> |
51 | 60 | <p> Value: {{ currentPokemon }} </p>
|
52 | 61 | <p> Touched: {{ pokemonControl.touched }} </p>
|
53 | 62 | <p> Dirty: {{ pokemonControl.dirty }} </p>
|
|
68 | 77 | <md-card>
|
69 | 78 | <md-card-subtitle>Without Angular forms</md-card-subtitle>
|
70 | 79 |
|
71 |
| - <md-select placeholder="Digimon" [(value)]="currentDigimon"> |
72 |
| - <md-option>None</md-option> |
73 |
| - <md-option *ngFor="let creature of digimon" [value]="creature.value"> |
74 |
| - {{ creature.viewValue }} |
75 |
| - </md-option> |
76 |
| - </md-select> |
| 80 | + <md-form-field> |
| 81 | + <md-select placeholder="Digimon" [(value)]="currentDigimon"> |
| 82 | + <md-option>None</md-option> |
| 83 | + <md-option *ngFor="let creature of digimon" [value]="creature.value"> |
| 84 | + {{ creature.viewValue }} |
| 85 | + </md-option> |
| 86 | + </md-select> |
| 87 | + </md-form-field> |
77 | 88 |
|
78 | 89 | <p>Value: {{ currentDigimon }}</p>
|
79 | 90 |
|
|
85 | 96 | <md-card-subtitle>Option groups</md-card-subtitle>
|
86 | 97 |
|
87 | 98 | <md-card-content>
|
88 |
| - <md-select placeholder="Pokemon" [(ngModel)]="currentPokemonFromGroup"> |
89 |
| - <md-optgroup *ngFor="let group of pokemonGroups" [label]="group.name" |
90 |
| - [disabled]="group.disabled"> |
91 |
| - <md-option *ngFor="let creature of group.pokemon" [value]="creature.value"> |
92 |
| - {{ creature.viewValue }} |
93 |
| - </md-option> |
94 |
| - </md-optgroup> |
95 |
| - </md-select> |
| 99 | + <md-form-field> |
| 100 | + <md-select placeholder="Pokemon" [(ngModel)]="currentPokemonFromGroup"> |
| 101 | + <md-optgroup *ngFor="let group of pokemonGroups" [label]="group.name" |
| 102 | + [disabled]="group.disabled"> |
| 103 | + <md-option *ngFor="let creature of group.pokemon" [value]="creature.value"> |
| 104 | + {{ creature.viewValue }} |
| 105 | + </md-option> |
| 106 | + </md-optgroup> |
| 107 | + </md-select> |
| 108 | + </md-form-field> |
96 | 109 | </md-card-content>
|
97 | 110 | </md-card>
|
98 | 111 |
|
99 | 112 |
|
100 | 113 | <md-card>
|
101 | 114 | <md-card-subtitle>compareWith</md-card-subtitle>
|
102 | 115 | <md-card-content>
|
103 |
| - <md-select placeholder="Drink" [color]="drinksTheme" |
104 |
| - [(ngModel)]="currentDrinkObject" |
105 |
| - [required]="drinkObjectRequired" |
106 |
| - [compareWith]="compareByValue ? compareDrinkObjectsByValue : compareByReference" |
107 |
| - #drinkObjectControl="ngModel"> |
108 |
| - <md-option *ngFor="let drink of drinks" [value]="drink" [disabled]="drink.disabled"> |
109 |
| - {{ drink.viewValue }} |
110 |
| - </md-option> |
111 |
| - </md-select> |
| 116 | + <md-form-field [color]="drinksTheme"> |
| 117 | + <md-select placeholder="Drink" |
| 118 | + [(ngModel)]="currentDrinkObject" |
| 119 | + [required]="drinkObjectRequired" |
| 120 | + [compareWith]="compareByValue ? compareDrinkObjectsByValue : compareByReference" |
| 121 | + #drinkObjectControl="ngModel"> |
| 122 | + <md-option *ngFor="let drink of drinks" [value]="drink" [disabled]="drink.disabled"> |
| 123 | + {{ drink.viewValue }} |
| 124 | + </md-option> |
| 125 | + </md-select> |
| 126 | + </md-form-field> |
112 | 127 | <p> Value: {{ currentDrinkObject | json }} </p>
|
113 | 128 | <p> Touched: {{ drinkObjectControl.touched }} </p>
|
114 | 129 | <p> Dirty: {{ drinkObjectControl.dirty }} </p>
|
|
130 | 145 | <md-card-subtitle>formControl</md-card-subtitle>
|
131 | 146 |
|
132 | 147 | <md-card-content>
|
133 |
| - <md-select placeholder="Food i would like to eat" [formControl]="foodControl"> |
134 |
| - <md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }}</md-option> |
135 |
| - </md-select> |
| 148 | + <md-form-field> |
| 149 | + <md-select placeholder="Food i would like to eat" [formControl]="foodControl"> |
| 150 | + <md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }}</md-option> |
| 151 | + </md-select> |
| 152 | + </md-form-field> |
136 | 153 | <p> Value: {{ foodControl.value }} </p>
|
137 | 154 | <p> Touched: {{ foodControl.touched }} </p>
|
138 | 155 | <p> Dirty: {{ foodControl.dirty }} </p>
|
|
149 | 166 | <md-card-subtitle>Change event</md-card-subtitle>
|
150 | 167 |
|
151 | 168 | <md-card-content>
|
152 |
| - <md-select placeholder="Starter Pokemon" (change)="latestChangeEvent = $event"> |
153 |
| - <md-option *ngFor="let creature of pokemon" [value]="creature.value">{{ creature.viewValue }}</md-option> |
154 |
| - </md-select> |
| 169 | + <md-form-field> |
| 170 | + <md-select placeholder="Starter Pokemon" (change)="latestChangeEvent = $event"> |
| 171 | + <md-option *ngFor="let creature of pokemon" [value]="creature.value">{{ creature.viewValue }}</md-option> |
| 172 | + </md-select> |
| 173 | + </md-form-field> |
155 | 174 |
|
156 | 175 | <p> Change event value: {{ latestChangeEvent?.value }} </p>
|
157 | 176 | </md-card-content>
|
|
0 commit comments