我想将api调用中的属性传递给提交函数,但不确定它为什么不起作用 . 我认为它与选项选择或重新格式化输入有关 .
遇到错误 Error: No value accessor for form control with name: 'employee_id'
form.component.html
<select>
<option
*ngFor="let employee of employees"
name="employee_id"
[(ngModel)]="employee_id">
{{ employee.name }}
</option>
</select>
<button
(click)="submitMeetingRequirements()"
class="btn btn-success">
Suggest Meeting
</button>
这是 form.component.ts
的提交功能
submitMeetingRequirements() {
this._meetingService.submitMeetingRequirements(
this.employee_id)
.subscribe(res => this.suggestions = res["suggestions"])
}
2 回答
固定的
使用
select
标签上的 [(ngModel)] 而不是option
标签 . 像这样的东西:这是你的参考Working Sample StackBlitz .