I am currently working on an Angular application where I need to populate dropdown lists from backend data.
.component.ts
public getMemberCodes() {
let baseUrl = `/endpoindAPI`;
this._restfulService
.restfulGetData(baseUrl)
.subscribe(
(actionLookupData: ActionLookupData) => {
if (actionLookupData) {
this.option1Codes = actionLookupData.Option1Codes;
this.option2Codes = actionLookupData.Option2Codes;
this.option3Codes = actionLookupData.Option3Codes;
}
},
(err) => {
console.error(err);
}
);
}
I need to extract Category values from the response like Option1Codes and Option2Codes to populate the dropdown lists with these values.
The structure of the response is as follows:
Option1Codes: [{Category: "Category1", ActionStatusTypeID: 1,Complete", ActionID: 5060,…}] Option2Codes: [{Category: "Category2", ActionStatusTypeID: 1,Complete", ActionID: 5060,…}]
My goal is to display only the Category values in the dropdown lists based on the backend data.
.component.html
<select class="form-control" required>
<option>
//code
</option>
</select>