html - angular ngFor:如何区分默认值与其他值
问题描述
我正在使用 ngFor 作为下拉 UI 元素。在下拉列表中,第一个条目用于传达信息(例如“请选择国家/地区”),其余是用户需要选择的值。
我希望第一个条目在外观上有点不同,就像变灰一样。
如何才能做到这一点?
解决方案
试试下面:
app.component.html
<div> Months :
<select (change) = "changemonths($event)" name = "month">
<option class="default-select" disebled>--select--</option>
<option *ngFor = "let i of months">{{i}}</option>
</select>
</div>
app.component.css
.default-select{
background-color:gray;
}
推荐阅读
- mongodb - 是否可以在使用副本集部署后将 Sharding 应用于 Mongo DB?
- php - PHP 根据日期将活动排序到正确的数组中
- ansible - Ansible 突然使用 svr4pkg 作为 yum 的后端
- javascript - 如何复制整行?
- python - 测量透明图像到实际图像的距离
- angular - InputMask 用于带有千点和十进制逗号的数字
- python - 我如何可视化熊猫中其他列的记录数
- python - ValueError:在 Linux 中使用 WGET 过滤来自 CLI 的简单 api 请求时,无法解码 JSON 对象
- python - Python Selenium 绕过检测?
- xpath - TIBCO 设计器中的“text()=0”是什么意思?