Reactive Form angular 7创建一个动态表单生成器,就像在.ts中使用JSON可以正常工作的链接一样,但是无法从HTTP请求中获取JSON。 https://stackblitz.com/edit/angular-wn34ld,但我从服务器获得的JSON响应
{
"Description": "Transformer Mapping",
"data": [
{
"name": "//Document",
"options": [
"InstructingAgentMmbId",
"InstructingAgentName"
],
"type": "select",
"value": ""
},
{
"name": "//DocumentLC",
"label": "List",
"type": "checkbox",
"value": "false"
}
],
"rescode": "0000",
"status": "Success",
"timestamp": "2019-06-18 20:06:44.168"
}
因此根据响应,我更改了接口模型和HTTP服务,但显示了错误
FormGroup需要一个FormGroup实例。请通过
regConfig:FieldConfig[];
export interface test {
data?: FieldConfig[];
}
this.http.post<test>('http://155.54.54.45:8080/Auto/transform/mapping', request).subscribe(res => {
this.regConfig =res.data;
console.log(this.regConfig)
});