我正在使用
这样的表单组this.PatientInfo = this.fb.group({
PatientID: [0],
Gender: '',
Name:'',
Employer: this.fb.group({
EmployerID: 0,
Name: [''],
EmployerAddresses: this.fb.group({
Address1: [''],
Address2: [''],
CityName: [''],
District: [''],
StateName: [''],
PostalCode: [''],
Country: ['']
})
})
});
我正在绑定像
这样的数据<div class="col-md-3" formGroupName="EmployerAddresses">
<div class="form-group form-group-default">
<label class="control-label">State</label>
<div class="input-group">
<input type="text" class="form-control" formControlName="StateCode">
</div>
</div>
</div>
在顶部,我将表格组保留为PatientInfo。
我在这里收到错误&#34;找不到名为EmployerAddresses&#34;的控件。
你可以请任何人帮忙吗?提前谢谢。
答案 0 :(得分:6)
此代码解决了我的问题。
this.PatientInfo = this.fb.group({
PatientID: [0],
Gender: '',
Name:'',
Employer: this.fb.group({
EmployerID: 0,
Name: [''],
EmployerAddresses: this.fb.group({
Address1: [''],
Address2: [''],
CityName: [''],
District: [''],
StateName: [''],
StateCode: [''],
PostalCode: [''],
Country: ['']
})
})
});
<div class="col-md-3" formGroupName="Employer">
<div class="form-group form-group-default" formGroupName="EmployerAddresses">
<label class="control-label">State</label>
<div class="input-group">
<input type="text" class="form-control" formControlName="StateCode">
</div>
</div>
</div>
谢谢...