I have the following data as JSON:
{
"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
}
]
}
]
}
}
and I want to display it as a html table with angularjs and ng-repeat.
so that I get the following table:
<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>
for table preview:
http://jsfiddle.net/54pD8/
my problem that the html table is working row-based.
I can iterate with ng-repeat through my Rounds and then through my excercises
but for creating a table I need always the first of each exercises then the second of each exercises and so on.
Can someone help me with this problem?
ps. if you have an idea for better layout for this data in json, your suggestions are welcome, I'm new to json (and angularjs).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…