我在角度6中面临这个问题.......不能绑定到'formgroup',因为它不是'form'的已知属性。 (QUOT; [英] Im facing this problem in angular 6 .......can't bind to 'formgroup' since it isn't a known property of 'form'. ("
本文介绍了我在角度6中面临这个问题.......不能绑定到'formgroup',因为它不是'form'的已知属性。 (QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
--------------------
in component
--------------------
ngOnInit() {
this.registerForm = this.formBuilder.group({
firstName: [],
lastName: [],
});
}
in html
--------------
in html
--------------
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()">
<div class="row">
<div class="col-md-4">
<mat-form-field class="example-full-width">
<input formControlName="firstName" matInput placeholder="Fist Name" type="text">
</mat-form-field>
</div>
<div class="col-md-4">
<mat-form-field class="example-full-width">
<input formControlName="lastName" matInput placeholder="Last Name" type="text">
</mat-form-field>
</div>
</div>
<button mat-raised-button type="submit" class="btn btn-danger pull-right">Register</button>
<div class="clearfix"></div>
</form>
appmodule
------------- -----
in appmodule
------------------
imports: [
BrowserModule,
CommonModule,
BrowserAnimationsModule,
HttpModule,
ComponentsModule,
RouterModule,
AppRoutingModule,
MatButtonModule,
MatFormFieldModule,
MatInputModule,
MatRippleModule,
HttpClientModule,
ReactiveFormsModule,
我尝试过:
i已尝试使用角度6表单组示例
What I have tried:
i have tried angular 6 form group example
推荐答案
将模块下方导入到当前组件所属的模块中。
Import below modules into module in which your current component belongs to.
FormsModule,
ReactiveFormsModule
这篇关于我在角度6中面临这个问题.......不能绑定到'formgroup',因为它不是'form'的已知属性。 (QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文