【发布时间】:2020-03-18 19:29:42
【问题描述】:
我只想将样式应用于父 <select> 标签,不包括其 <option> 子标签。
请看下面的代码:
I want that whenever the first option is selected, my style 'highlight' should to applied to <select>.其他<option> 标签应该不受影响。
我想内联而不是使用组件级 css。 这是由于一些设计/编码准则的限制,因为所有样式都是从预定义的主样式表中获取的,并且很少添加新样式。
<select [ngClass]="{ 'highlight': selectedUser === undefined }" [(ngModel)]="selectedUser">
<option [ngValue]="undefined">
Select User
</option>
<option *ngFor="let user of users" [value]="user">
{{ user.name }}
</option>
</select>
【问题讨论】:
标签: css angular stylesheet