【发布时间】:2017-04-15 02:30:20
【问题描述】:
在 Angular 2 模板驱动的表单中,我可以编写
<form #form="ngForm">
[...]
</form>
ngForm 是一个 FormGroup,据我所知。如何在相应的组件中抓取该对象?
class FormComponent {
formGroup: FormGroup; // How do I have the form INJECTED AUTOMATICALLY by the framework? Something like a ViewChild, but it's not a view
}
一定要简单,但是文档只展示了如何使用模板中的表格。
谢谢
编辑:我要抓取的类型是 NgForm,而不是 FormGroup!
【问题讨论】:
标签: forms angular angular2-forms