我有一个选择,但是默认选项“ Primeiro filtro”没有显示:
我的模板:
<div class="select">
<select [(ngModel)]="controlaRadios" name="tipoDoProdutoName" class="select-text">
<option class="dropdown-item" disabled selected value>Primeiro filtro</option>
<option value="1" class="dropdown-item">Todos</option>
<option value="2" class="dropdown-item">Tipo de anúncio</option>
</select>
<span class="select-highlight"></span>
<span class="select-bar"></span>
</div>
TS:
controlaRadios: any = "Primeiro filtro"
答案 0 :(得分:2)
在这里看看并尝试适应。希望这会有所帮助。
.html
<select class="form-control" type="text" [(ngModel)]="selectedType">
<option *ngFor="let type of types" [ngValue]="type">{{type}}</option>
</select>
.ts
types: Array<Object> = ['Default option', 'First option', 'Second option']
selectedType = this.types[0];
答案 1 :(得分:0)
尝试一下。希望它对你有用:)
<select [(ngModel)]="controlaRadios" name="tipoDoProdutoName" class="select-text">
<option value="Primeiro filtro" class="dropdown-item">Primeiro filtro</option>
<option value="1" class="dropdown-item">Todos</option>
<option value="2" class="dropdown-item">Tipo de anúncio</option>
</select>
<span class="select-highlight"></span>
<span class="select-bar"></span>
</div>