My GET request is fetching data from a REST API, and this is the response I receive:
{
"listCustomFields": [
{
"configurationType": null,
"errorDetails": null,
"fieldId": "312329",
"listItems": [
"Banking Services",
"Business Banking",
"Commercial",
"Consumer Lending"
],
"name": "Department Name",
"required": "true",
"show": "true",
"value": null
},
{
"configurationType": null,
"errorDetails": null,
"fieldId": "373914",
"listItems": [
"BB Account Servicing - Add/delete signer",
"BB Account Servicing - Online Banking for Business - Add Business Account Form",
"BB Lending - Express Business Credit Application"
],
"name": "Documents being sent",
"required": "false",
"show": "true",
"value": null
}
],
// more nested JSON objects here...
}
When I try to display the listItems object within the listCustomFields Array in an option tag, the whole list appears on one line.
This is my API call:
getCustomFields(): Observable<any> { return this.http.get(this.apiUrl); }
This is my method:
getCustomField(){ this.customFieldService.getCustomFields().subscribe((res) => { this.data = res; console.log(this.data); }); }
And here is the relevant HTML snippet:
<select id="dropdown" name="listCustomFields" class="form-select" formControlName="listCustomFields" >
<option *ngFor="let d of data.listCustomFields; let index = index;"><ng-container *ngIf="index===0">{{ d.listItems }}</ng-container>
</option>
</select>
I'm facing some issues with the formatting. Any guidance would be highly appreciated.