相关疑难解决方法(0)

Angular 2:如何从表单的不同选项中获取所选值?

我想<select>在表单中使用a 让用户能够更新不同的值<option>.我使用了指南中的技术:https://angular.io/docs/ts/latest/guide/forms.html.这是我正在谈论的样本:

<div class="form-group">
    <label for="type">Type :</label>
    <select class="form-control" [(ngModel)]="order.type" ngControl="type">
        <option *ngFor="#type of types" [value]="type">{{type}}</option>
    </select>
</div>
Run Code Online (Sandbox Code Playgroud)

在我的order-details.component中,我有一个updateOrder(),它从myApp.services调用updateOrder().

我的问题是当我尝试将数据从表单发送到后端时:所有具有a的部分<input>都可以,但不是那些<select>(它返回原始值,而不是选择的那个).

有没有人遇到过这个或类似的问题?谢谢你的帮助!

forms html-select angular-ngmodel angular2-forms angular

11
推荐指数
2
解决办法
4万
查看次数