【发布时间】:2018-07-09 02:42:58
【问题描述】:
我正在尝试获取要在响应式表单提交时发送的更改事件下拉列表的选定值。根据how to get selected value of radio in reactive form的回答,我有一个非常相似的无线电工作场景@
这是下拉菜单的代码
<div class="row" *ngIf="question.controls.type.value === 'dropdown'">
<div class="col-md-12">
<div class="form-group__text select">
<label for="type">{{ question.controls.label.value }}</label>
<br><br>
<select name="value" formArrayName="component" (change)="updateSelection(question.controls.component.controls, $event.target)">
<option
*ngFor="let answer of question.controls.component.controls; let j = index" [formGroupName]="j"
[ngValue]="answer?.value?.value">
{{answer?.value?.value}}
</option>
</select>
</div>
</div>
</div>
在更改下拉列表中的选定选项时,我无法将答案作为 formcontrol 传递给 updateSelection。非常感谢任何帮助。
【问题讨论】:
-
你想要什么?你想得到哪个选项被选中?
-
是的,阿伦!对于从下拉列表中选择的选项,我希望 selectedValue 为 true。
标签: angular-reactive-forms angular4-forms formarray formgroups