angular 7 HTTP请求动态表单不工作
被动表单7创建一个动态表单生成器,就像在.ts中使用JSON时链接工作正常一样,但不能从HTTP请求中获取JSON。 但是我从服务器得到的JSON响应angular 7 HTTP请求动态表单不工作,angular,typescript,angular7,angular-reactive-forms,Angular,Typescript,Angular7,Angular Reactive Forms,被动表单7创建一个动态表单生成器,就像在.ts中使用JSON时链接工作正常一样,但不能从HTTP请求中获取JSON。 但是我从服务器得到的JSON响应 { "Description": "Transformer Mapping", "data": [ { "name": "//Document", "options": [ "InstructingAgentMmbId",
{
"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[];
导出接口测试{
数据?:FieldConfig[];
}
this.http.post('http://155.54.54.45:8080/Auto/transform/mapping,请求)。订阅(res=>{
this.regConfig=res.data;
console.log(this.regConfig)
});
我没有错误提供您的html代码,这样我们就可以很容易地发现在ts中使用JSON时没有错误,但使用http服务不起作用
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)
});