I got an array with objects similar to:
{
_id: "0",
category: "ptr",
price: 14.5
}
So I'm printing an HTML table this way:
<tr ng-repeat="product in products.categoryQuery">
<td>{{product._id}}</td>
<td>{{product.category}}</td>
<td>{{product.price}}</td>
</tr>
Being queryCategory
an array with my objects. I wonder if I can reduce the HTML and add an ng-repeat
directive at a <td>
for iterating over object's attributes.
I tried:
<td ng-repeat"p for p in product">{{p}}</td>
and
<td ng-repeat"p for p in product">{{product[p]}}</td>
But got not results. How could I achieve it?
Edit.
As critics suggest, there's this alternative when it's got one single object:
<tr ng-repeat="(key, value) in data">
<td> {{key}} </td> <td> {{ value }} </td>
</tr>
But how can I use it when they're several objects from an array?