且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

添加占位符以选择angular2中的标签

更新时间:2023-11-26 16:15:34

我通过执行以下操作使它起作用:

I got this to work by doing the following:

enter code here

<div class="form-group">
  <label for="metricsType">metrics type</label>
  <select id="metricsType" class="form-control" required [(ngModel)] ="model.metrics.type">
     <option value="" disabled="true" [selected]="!model.metrics.type">--please select--</option>
     <option *ngFor="let item of metricTypes" [value]="item.value">{{item.label}}</option>
  </select>
 </div>

然后使用css ng-pristine进行样式设置

then using css ng-pristine for styling

select {
 border: 1px solid transparent;
  &.ng-pristine{
    font-style: italic;
    color: darken($white, 50%);
  }
}