AngularJS Multiple ng-repeats on single row of table

前端 未结 1 1151
甜味超标
甜味超标 2021-01-21 10:37

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

1条回答
  •  情话喂你
    2021-01-21 11:31

    Yes, quite possible.

    Assuming an array of parent objects called parents and that parent.child itself is an array of child 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.

    parent.item1 parent.item2 parent.item3 child.item1 child.item2

    Update:

    Since the OP seems to want separate child rows grouped by parent, this might be the solution sought:

    parent.item1 parent.item2 parent.item3 child.item1 child.item2

    0 讨论(0)
提交回复
热议问题