Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

in angularjs i want show a table with two columns: the header of the first column is "Type" and the second column is "Product".

In the controller i have the following structure (in the chrome debugger):

products: Array[0]
    drink:Array[12]
      0: Object
      1: Object
      ....
      ....

So i have a "products" array with "drink" key with associate an array of objects (12 items)

In angularjs, with ng-repeats, how can i show as many rows as the number of products items (and show in the Type column the "drink" key) and in the column Product all the objects (only the name) associated with the key?

Thanks

share|improve this question
1  
What did you try? –  Jeremy Thille Mar 25 at 14:57
    
Do provide us with the snippet of code of what you have attempted :) –  SWLim Mar 25 at 15:03
    
i don't have tried because i don't know how to do –  Tom Mar 25 at 15:03
    
If you know how to do a basic ng-repeat, this is not hard to achieve. You should try a few easy ones, and you will find the solution quickly. Do one ng-repeat. –  Jeremy Thille Mar 25 at 15:26

1 Answer 1

Instead of id and name put the attribute name which your object have:

<table>
<tr ng-repeat="obj in products[0].drink">
<td>{{ obj.id}}</td>
<td>{{ obj.name}}</td>
</tr>
</table>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.