html - Angular 5:选择列表选项文本的不同前景色
问题描述
我想用不同的颜色为选择列表选项的前景着色:以下是我的下拉列表的代码:
<select id="tier" class="form-control" [(ngModel)]="tierId">
<option *ngFor="let m of tierList" value="{{m.tier}}" >
{{m.optiontext}} | {{m.count}}
</option>
</select>
我想以蓝色显示选项文本并以红色计数。无论如何我可以做到这一点吗?
解决方案
本机<select>
不支持选项中的多种颜色。
您可以尝试其他库,例如 @angular/material。
例如:
<mat-select id="tier" [(value)]="tierId">
<mat-option *ngFor="let m of tierList" [value]="m.tier">
<span style="color: blue;">{{m.optiontext}}</span> |
<span style="color: red;">{{m.count}}</span>
</mat-option>
</mat-select>
有关更多信息,请参阅https://v5.material.angular.io/components/select/examples
推荐阅读
- sql-server-data-tools - 需要帮助使用代码将数据库引用添加到数据库项目
- ruby-on-rails - Ruby On Rails Searchkick gem 错误:“NGram Tokenizer 中的 max_gram 和 min_gram 之间的差异必须小于或等于:[1]
- python - 在 python 中修改模块的最佳方法是什么?
- arrays - 找到一对互质数
- angular - Angular 5->8 升级后,材质对话框显示在 DOM 中,但不呈现在屏幕上
- amazon-web-services - NestJS:图像上传和服务 API
- python - Django-rest ,返回自定义的 Json
- spring - 忽略 URL 路径变量值中的“/”
- vba - 如何解决访问查询中的运行时错误 3075
- ios - 我使用手机时没有收到“onPushTokenReceivedCallback”