У меня есть следующие два массива.
Массив посещаемости студентов
"student_attendance": [
{
"month": "March",
"item": [
{
"year": 2018,
"day": 5,
"status": "Absent"
},
{
"year": 2018,
"day": 6,
"status": "Present"
}
]
},
{
"month": "April",
"item": [
{
"year": 2018,
"day": 2,
"status": "Present"
},
{
"year": 2018,
"day": 3,
"status": "Leave"
}
]
},
{
"month": "May",
"item": [
{
"year": 2018,
"day": 1,
"status": "Absent"
},
{
"year": 2018,
"day": 2,
"status": "Present"
}
]
}
]
Массив дней
day_arr : [
{month: "March",
item: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]},
{month: "April",
item: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]},
{month: "May",
item: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30, 31]},
]
Это моя попытка
<ng-container *ngFor="let d of day_arr;">
<ng-container *ngFor="let i of att.item;">
<ng-container *ngIf="att.month == d.month">
<ng-container *ngFor="let di of d.item;">
<td *ngIf="att.month == d.month && di == i.day;else not">
{{ i.status }}
</td>
<ng-template #not>
<td>{{ "-" }}</td>
</ng-template>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
Я сталкиваюсь с проблемой, что как связать данные с двумя циклами?Я хочу нарисовать стиль 2, но получаю стиль pic1.И тогда я не знаю, как сломать * ngFor?Любая помощь будет оценена. Спасибо заранее.
Pic 1 ![enter image description here](https://i.stack.imgur.com/KupQi.png)
Pic2 ![enter image description here](https://i.stack.imgur.com/Yayoe.png)