【发布时间】:2022-01-10 03:09:49
【问题描述】:
我正在尝试在我的 Angular 应用程序的选项下拉列表中的默认项目之前应用一个刻度线。如本例所示,它的名字是 steven。我如何做到这一点
由于某种原因,它似乎不适用
我创建了一个堆栈闪电战来重现该问题 https://stackblitz.com/edit/angular-ivy-qac8ae?file=src/app/app.component.html
标记
<form [formGroup]="form">
<div class="wrapper">
<div class="select-wrapper-row">
<select formControlName="name">
<option value="">-- Select an option --</option>
<option
*ngFor="let item of nameList$ | async"
[ngClass]="{ checkmark: item.isAlive == true }"
[selected]="item.isAlive"
>
{{ item.name }}
</option>
</select>
</div>
</div>
</form>
CSS
.checkmark:before {
content: 'L';
font-family: arial;
-ms-transform: scaleX(-1) rotate(-35deg); /* IE 9 */
-webkit-transform: scaleX(-1) rotate(-35deg); /* Chrome, Safari, Opera */
transform: scaleX(-1) rotate(-35deg);
display: inline-block;
vertical-align: top;
line-height: 1em;
width: 1em;
color: white;
height: 1em;
margin-right: 0.6em;
text-align: center;
position: absolute;
right: 0;
}
【问题讨论】:
-
请提供一个 StackBlitz 示例 - 这样更容易获得帮助。
-
我添加了一个 stackblitz 示例#dopoto
-
您是否调查过原生 html 选择是否真的允许您这样做?
-
我尝试将样式放在原生选择 css 中。不知道你是不是这个意思
-
我遇到了这个链接。这里看到的主要区别是它使用了材质选项按钮stackblitz.com/edit/…