在mat-select模块中选择值之后,我需要为每个mat-option元素动态添加样式。下面是我用来添加权限列表的代码
permissions.component.html
<mat-form-field class="input-permissions">
<mat-select placeholder="Permissions" multiple>
<mat-option
*ngFor="let permission of permissions"
[value]="permission.id"
>
{{ permission.appPermissions }}
</mat-option>
</mat-select>
</mat-form-field>
这就是我想要的,
这就是我现在得到的方式,
我试图通过使用浏览器中的inspect功能来添加样式,但是所选值存在于一个span类中,因此它将为整个字段本身添加样式。