I have a data something like:
"data": [
{
"name": "Joe"
},
{
"location": "USA"
},
{
"age": "unknown"
}
]
NOTE: this object could be vary (not the fixed length).
I am displaying in the form like:
name(as a label): Joe (as an input value)
location(as a label): USA (as an input value)
age(as a label): unknown (as an input value)
app.component.html:
<form [formGroup]="angularForm">
<div class="key-value-container" *ngFor="let item of values">
<div class="key-value">
<div class="key-value-lable">
<label class="label">{{item.key}}</label>
</div>
<div class="input-container">
<input class="input-text" matInput value="{{item.value}}">
</div>
</div>
</div>
<button type="button" class="primary-button" mat-flat-button (click)="_updateForm()">Update</button>
</form>
I want to UPDATE the data by POST method when I click on "_updateForm()" like:
{
"key1" (name):"value1"(updated_name),
"key2" (location):"value2"(updated_location),
"key3"(age):"value3" (updated_age)
}
and how can I create formControlerName for this form?