【发布时间】:2017-04-10 14:43:26
【问题描述】:
您好,我有以下数据结构,
this._days=[
{
"day": "",
"timing": {}
},
{
"day": "Monday",
"timing": [
{'9:00AM-10:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'10:00AM-11:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'11:00AM-12:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'12:00AM-13:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'13:00AM-14:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}}
]
},
{
"day": "Tuesday",
"timing": [
{'9:00AM-10:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'10:00AM-11:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'11:00AM-12:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'12:00AM-13:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}},
{'13:00AM-14:00AM': {'subject': 'Physics','teacher': 'Amanda','Location': 'Room 05'}}
]
},
...
我想显示像
这样的值在我尝试过的html中,
<table width="100%" align="center" height=100%;>
<tr class="day">
<th *ngFor="let row of _days">{{row.day}}</th>
</tr>
<tr class="time" *ngFor="let x of _days.timing">
<th style="width:100px">{{_days.timing[x][key]}}</th>
<td>{{_days.timing[x].value}}</td>
</tr>
</table>
无论如何,我可以在我的html中实现这一点,这样我就可以获得如图所示的预期结果。在此先感谢各位。
【问题讨论】:
-
这里你错了
<tr class="time" *ngFor="let x of _days.timing">这里你分配了_days.timing这没什么
标签: javascript jquery html angular typescript