角度2设置组合框值以编程方式

时间:2017-02-28 15:33:54

标签: angular combobox angular2-forms

我在组件中设置组合框的值时出现问题。组合框的值加载在levelCombined [j] [i] ['结果']

                <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。

1 个答案:

答案 0 :(得分:1)

使用[(ngModel)]将默认选项与组件的值绑定。

相关问题