首页 文章

如何在角度材料中显示图标选择<mat-option>并选择相同的图标

提问于
浏览
4

如何使用材料选择控件在选择下拉控件内正确显示图标 . 选择mat选项后,它选择图标文本以及如何克服这个问题?

<mat-form-field>
                <mat-select formControlName="genderFormControl" placeholder="Gender">
                    <mat-option>None</mat-option>
                    <mat-option *ngFor="let gender of genders" [value]="gender.value">
                            <mat-icon matListIcon>pregnant_woman</mat-icon>
                            {{gender.name}}
                    </mat-option>
                </mat-select>
            </mat-form-field>

enter image description here


enter image description here

1 回答

  • 2

    您可以通过 "mat-select-trigger" 选项完成它 .

    <mat-select-trigger>
          <mat-icon>pregnant_woman</mat-icon>&nbsp;{{gender.name}}
       </mat-select-trigger>
    

    关于 mat-select-trigger. 的更多文档

相关问题