【发布时间】:2016-04-29 06:10:24
【问题描述】:
我想在表单中使用<select>,让用户能够更新不同<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>
在我的 order-details.component 中,我有一个 updateOrder(),它从 myApp.services 调用 updateOrder()。
我的问题是当我尝试将数据从表单发送到后端时:所有带有 <input> 的部分都可以,但不是带有 <select> 的部分(它返回原始值,而不是被选中的那个)。
有没有人遇到过这个或类似的问题? 感谢您的帮助!
【问题讨论】:
标签: forms html-select angular angular-ngmodel angular2-forms