/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/components-examples/material/select/select-hint-error/select-hint-error-example.html
29 строк
1009 B
Kristiyan Kostadinov
docs(multiple): switch docs examples to new control flow
06 ноя 2023, 18:51
06 ноя 2023, 18:51
99b62ba
Код
Авторство
О чём код?
<h4>mat select</h4> <mat-form-field> <mat-label>Favorite animal</mat-label> <mat-select [formControl]="animalControl" required> <mat-option>--</mat-option> @for (animal of animals; track animal) { <mat-option [value]="animal">{{animal.name}}</mat-option> } </mat-select> @if (animalControl.hasError('required')) { <mat-error>Please choose an animal</mat-error> } <mat-hint>{{animalControl.value?.sound}}</mat-hint> </mat-form-field> <h4>native html select</h4> <mat-form-field> <mat-label>Select your car (required)</mat-label> <select matNativeControl required [formControl]="selectFormControl"> <option label="--select something --"></option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> @if (selectFormControl.hasError('required')) { <mat-error>This field is required</mat-error> } <mat-hint>You can pick up your favorite car here</mat-hint> </mat-form-field>