I am having problem iterating to through json object.
Here is the Json sample:
floors.ts
this.floors= [
{
floorName: "floor 1",
result: [
{
resFloor: "1",
floorResult: [
{
roomNum: "room 1",
roomResult: [
{
bedNum: "1"
},
{
bedNum: "2"
},
{
bedNum: "3"
}
],
},
{
roomNum: "room 2",
roomResult: [
{
bedNum: "1"
},
{
bedNum: "2"
},
{
bedNum: "3"
}
],
},
{
roomNum: "room 3",
roomResult: [
{
bedNum: "1"
},
{
bedNum: "2"
},
{
bedNum: "3"
}
],
},
],
}
],
}
]
floor-template.html
<button *ngFor="let i of floors">
{{i.floorName}}
<div *ngIf="clicked">
<button *ngFor="let j of i.result">
{{j.resFloor}}
<div *ngIf="clicked">
<button *ngFor="let k of j.floorResult">
{{k.roomNum}}
</button>
</div>
</button>
</div>
What I am trying to do is that I want to iterate through this json. In ngIf, clicked is boolean and if it is set to true then it gives me result for all ngFor loops and then it gives me an error; and if it is set to false then nothing comes up except the result of 1st for loop and then that button is doing nothing. What am I doing wrong. Please point into the right direction. Thanks!!


EXCEPTION: Cannot read property 'floorResult' of undefined