I have a component that retrieves data from the back-end and groups it accordingly.
Below is the code snippet:
getRecruitmentAgencyClientPositions(): void {
this._recruitmentAgencyClientsService.getRecruitmentAgencyClientPositions(this.recruitmentAgencyClientId).subscribe(r => {
this.groupedArray = _.groupBy(r.items, 'groupIdentifier');
console.log(this.groupedArray);
});
}
This is an example of how I formatted the data:
{
"57a5bcdf-fdf0-494a-ba94-8c50ebb716cf": [
{
"groupIdentifier": "57a5bcdf-fdf0-494a-ba94-8c50ebb716cf",
"salary": 100,
"commission": 5,
"recruitmentAgencyClientId": 10,
"isDeleted": false,
"deleterUserId": null,
"lastModifierUserId": null,
"creationTime": "2020-11-27T18:00:48+02:00",
"creatorUserId": 3,
"id": 5
}
],
"00000000-0000-0000-0000-000000000000": [
{...},
...
]
}
I'm attempting to generate tables based on the grouping like this:
<div *ngFor="let item of groupedArray">
<div class="primeng-datatable-container positions-table" [busyIf]="primengTableHelper.isLoading">
<p-table ... >
... table structure ...
</p-table>
<div class="primeng-no-data" *ngIf="!primengTableHelper.records">
{{ 'NoData' | localize }}
</div>
</div>
</div>
However, I'm encountering an error message:
Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays
How can I resolve this issue?