I have the following Problem in my Angular Project. I get the following Data (example Data) from our API:
{
"plant": [
{
"workplateId": 0,
"workplaceTypeId": 0,
"description": "string",
"aktiveOrder": 0,
"spsActive": true,
"plantActive": true,
"plantStatus": 0,
"orderManagementActive": true,
"Cycle": 0
},
{
"workplateId": 1,
"workplaceTypeId": 0,
"description": "string",
"aktiveOrder": 0,
"spsActive": false,
"plantActive": false,
"plantStatus": 0,
"orderManagementActive": true,
"Cycle": 0
}
],
"productFig": {
"earlyShift": [
{
"plantId": 0,
"shiftId": "string",
"quant101": 0,
"sqm101": 0,
"quant531": 0,
"sqm531": 0,
"quant532": 0
},
{
"plantId": 1,
"shiftId": "string",
"quant101": 100,
"sqm101": 1000,
"quant531": 0,
"sqm531": 0,
"quant532": 0
}
],
"lateShift": [
{
"plantId": 0,
"shiftId": "string",
"quant101": 0,
"sqm101": 0,
"quant531": 0,
"sqm531": 0,
"quant532": 0
},
{
"plantId": 1,
"shiftId": "string",
"quant101": 2000,
"sqm101": 20000,
"quant531": 0,
"sqm531": 0,
"quant532": 0
}
],
"nightShift": [
{
"plantId": 0,
"shiftId": "string",
"quant101": 0,
"sqm101": 0,
"quant531": 0,
"sqm531": 0,
"quant532": 0
}
]
}
}
Iam storing the data in a property from type Data[]. The Data type is an interface. This works without a problem and I can access the whole data here in my component.ts:
this.store.pipe(select(getAllData)).
subscribe(data => {
this.data = data;
console.log(data);
});
But when i try to access it in my html I get the following error:
Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed
My implementation is:
<ov-plant *ngFor="let p of data"></ov-plant>
I need to access the plant array from datta, so the first array from data. It might be a simple issue for you guys, but I hope someone can lend me a hand :).
Thanks in Advance!
datavariable is an object butngForexpects something that can be iterated. Try*ngFor="let p of data.plant"