Angular 角度6-占位符文本对于选择选项列表不可见

Angular 角度6-占位符文本对于选择选项列表不可见,angular,angular6,angular-reactive-forms,Angular,Angular6,Angular Reactive Forms,在我的windows 10笔记本电脑的chrome浏览器版本71中,我看不到选择列表占位符 目前只看到白色空白而不是占位符文本 这是我的html表格: 这就是我所看到的: 以下是可能对您有所帮助的代码:- app.component.html:- <select> <option class="placeholder" selected disabled value="">Select language</option>

在我的windows 10笔记本电脑的chrome浏览器版本71中,我看不到选择列表占位符

目前只看到白色空白而不是占位符文本

这是我的html表格:

这就是我所看到的:


以下是可能对您有所帮助的代码:-

app.component.html:-

<select>
          <option class="placeholder" selected disabled value="">Select 
          language</option>
          <option *ngFor="let option of field.options" [value]="option.name"> 
          {{option.name}}</option>
</select>
试试这个:

 public createForm(): void {
   this.form = this.formBuilder.group({
    sector: [ null, Validators.required ]
  });
}

在模板中:

 <select formControlName="sector" class="col-12 field">
        <option value="null" disabled selected hidden >Select Sector*</option>
        <option [value]="sector" *ngFor="let sector of jobOptions.sectors">{{ sector }}</option>
      </select>
就我而言,添加required起了作用

<select formControlName="sector" class="col-12 field" required>
   <option value="null" disabled selected hidden>Select Sector*</option>
   <option [value]="sector" *ngFor="let sector of jobOptions.sectors">
      {{ sector }} 
   </option>
</select>

但这不会隐藏占位符吗?我想用默认值显示它问题与如何显示selectCheck的占位符有关检查此项:
 public createForm(): void {
   this.form = this.formBuilder.group({
    sector: [ null, Validators.required ]
  });
 <select formControlName="sector" class="col-12 field">
        <option value="null" disabled selected hidden >Select Sector*</option>
        <option [value]="sector" *ngFor="let sector of jobOptions.sectors">{{ sector }}</option>
      </select>
<select formControlName="sector" class="col-12 field" required>
   <option value="null" disabled selected hidden>Select Sector*</option>
   <option [value]="sector" *ngFor="let sector of jobOptions.sectors">
      {{ sector }} 
   </option>
</select>