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