【发布时间】:2020-07-22 23:21:56
【问题描述】:
我正在使用 Select2 显示通过 REST API 获得的选项列表。 我目前正在以这种方式显示我的数据。
我特别期待以粗体字体粗细样式出现的“Volvo”一词。
这是我渲染数据的<select>标签文件。
<select formControlName="modCar" class="form-control select2" style="width:90%" [ngClass]="{ 'is-invalid': submitted && f.modCar.errors }">
<option *ngFor="let item of arrCarroc; index as i" value="{{item.id}}">
{{item.nombre}} - {{item.nombreMarca}}</option>
</select>
我已经尝试在{{item.nombreMarca}}元素之间放置一个<b>标签,在Angular-component CSS中定义一个自定义标签,重新定义Select2 CSS类select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}但仍然没有得到结果。
【问题讨论】:
-
您是否尝试过使用
<strong>?也看看 Select2templateResultSelect2Docs -
非常感谢,陈娜!您的回答对我非常有用,我实现了我想要的。
标签: html css angular jquery-select2