I received some data from the back-end which is being written to a form, and it's in the form of an array of objects
Below is the code snippet:
this.companyDetailsForm = new FormGroup({
directors : new FormControl(response?.companyDirectors)
});
Next, I iterate over the data in HTML using ngFor like so:
<div *ngFor="let director of companyDetailsForm.controls['directors'].value; let i = index" class="form-group start-aligned" style="margin-left: 69px;margin-right: 69px">
<label>{{'Director' | localize}} {{i+1}}</label>
<input disabled type="text" class="form-control" pInputText formControlName="director.name" />
</div>
Here is how each director object looks like:
{ "id": 51, "name": "DIRECTOR, Test" }
If you need to add the 'name' field data to the input, here's how you can do it.