我有以下两个数组。
学生出勤数组
"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"
}
]
}
]
Days Array
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?任何帮助将不胜感激。谢谢。