[英]How to make Angular Reactive (Dynamic) form with API Response data? Need advise
[
{
"name": "jkjk",
"firstName": "hgh",
"lastName": "ehtrh",
"replytype": "svdv",
"prodCode": "svv",
"executor": "ewwe",
"skills": [
{},
{}
]
},
{
"name": "sdkjbdsf",
"firstName": "kdvbfd",
"lastName": "dkbd",
"replytype": "SQLServer",
"prodCode": "vsdv",
"executor": "vkjbndsf,vd",
"skills": [
{
"name1": "abs"
},
{
"name2": "bbs"
}
]
}
]
In this case I recommend you to use a *ngFor
loop and generate your inputs.在这种情况下,我建议您使用*ngFor
循环并生成您的输入。
Add keys as the name
property and the values as value.将键添加为name
属性,将值添加为值。
Then you can post the data as the usual way back.然后您可以像往常一样发布数据。
<form>
<div *ngFor="let item of array">
<ng-container *ngFor="let i of item | keyvalue">
<input [name]=i.key [value]="i.value" />
</ng-container>
</div>
<button type="submit" (click)="edit()"></button>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.