0
我有一個設置組件值的ComboBox的問題。組合框的值在levelCombined [j] [i] ['result']中加載angular 2以編程方式設置組合框的值
<tr *ngFor="let x of levelCombined, let j=index">
<td *ngFor="let y of x, let i=index">
<select class="form-control" id="comboBoxLevelSelction"
name="levelSelection"
(change)="onLevelSelect($event,j,i)">
<option disabled selected value> - select an option -</option>
<option *ngFor="let ln of levelNames" [ngValue]="levelCombined[j][i]['result']">{{levelCombined[j][i]['result']}}</option>
</select>
</td>
</tr>
當前所有組合框都設置爲默認選項。我認爲我沒有正確使用ngValue。
您可以使用屬性綁定語法'[value] =「您的值」'。有關綁定不同表單控件的更多細節可以在這裏找到。 [https://scotch.io/tutorials/how-to-deal-with-different-form-controls-in-angular-2](https://scotch.io/tutorials/how-to-deal-with- different-form-controls-in-angular-2) – HirenParekh