I am trying to display a table with items from both a parent and a list of child objects. Is it possible to do this using ng-repeat? A for loop would look something like this.
foreach(var parent in list)
foreach (var child in parent)
print(parent.1)
print(parent.2)
print(child.1)
print(child.2)
Below is the general idea of what each row would look like.
<table>
<tr ng-repeat="parent in list">
ng-repeat="child in parent"
<td>parent.item1</td>
<td>parent.item2</td>
<td>parent.item3</td>
<td>child.item1</td>
<td>child.item2</td>
</tr>
</table>
Yes, quite possible.
Assuming an array of
parent
objects calledparents
and thatparent.child
itself is an array ofchild
objects, as it seems to be in your example, you would then do the following using the special ng-repeat-start and ng-repeat-end forms of ngRepeat.Update:
Since the OP seems to want separate child rows grouped by parent, this might be the solution sought: