创建表,我有以下数据作为JSON:从JSON数据与angularjs和NG-重复
{
"Workout1": {
"Name": "First",
"Rounds": [
{
"Exercises": [
{
"Name": "Exercise1",
"Repeat": 10
},
{
"Name": "Exercise2",
"Repeat": 10
},
{
"Name": "Exercise3",
"Repeat": 10
}
]
},
{
"Exercises": [
{
"Name": "Exercise1",
"Repeat": 20
},
{
"Name": "Exercise2",
"Repeat": 20
},
{
"Name": "Exercise3",
"Repeat": 20
}
]
},
{
"Exercises": [
{
"Name": "Exercise1",
"Repeat": 30
},
{
"Name": "Exercise2",
"Repeat": 30
},
{
"Name": "Exercise3",
"Repeat": 30
}
]
}
]
}
}
,我想以显示它与angularjs和NG-重复一个HTML表格。 让我得到如下表:
<table class="table">
<tr>
<th>Round1</th>
<th>Round2</th>
<th>Round3</th>
</tr>
<tr>
<td>10 Exercise1</td>
<td>20 Exercise1</td>
<td>30 Exercise1</td>
</tr>
<tr>
<td>10 Exercise2</td>
<td>20 Exercise2</td>
<td>30 Exercise2</td>
</tr>
<tr>
<td>10 Exercise3</td>
<td>20 Exercise3</td>
<td>30 Exercise3</td>
</tr>
</table>
为表预览: http://jsfiddle.net/54pD8/
我的问题是,HTML表正在基于行。 我可以用ng-repeat循环遍历我的回合,然后通过我的excercises ,但创建表格时,我总是需要每个练习的第一个,然后是每个练习的第二个,等等。
有人可以帮我解决这个问题吗?
ps。如果您对json中的这些数据有更好的布局的想法,欢迎您提出建议,我是json(和angularjs)的新手。
更新下面的例子中使用的表,而不是李。请注意ng:repeat仍被使用。 –