I need to display a table with some basic information about products in my AngularJS app, something like this:
<table>
<tbody>
<tr class="product-image">
<td class="mar-b-0 pad-b-0">
<img src="../image/product1.jpg" alt="product name" />
</td>
<td class="mar-b-0 pad-b-0">
<img src="../image/product2.jpg" alt="product name" />
</td>
<td class="mar-b-0 pad-b-0">
<img src="../image/product3.jpg" alt="product name" />
</td>
<td class="mar-b-0 pad-b-0">
<img src="../image/product4.jpg" alt="product name" />
</td>
</tr>
<tr class="prod-name">
<td><a href="#">Product 1</td>
<td><a href="#">Product 2</td>
<td><a href="#">Product 3</td>
<td><a href="#">Product 4</td>
</tr>
</tbody>
</table>
The products are in a scope variable in my controller and to generate the table code I used the following logic:
<table>
<tbody>
<tr class="product-image">
<td ng-repeat="product in productsList" class="mar-b-0 pad-b-0">
<img src="{{ product.image }}" alt="product name" />
</td>
</tr>
<tr class="prod-name">
<td ng-repeat="product in productsList"><a href="#">{{ product.name }}</td>
</tr>
</tbody>
</table>
But I find this highly inefficient because I'll have to display multiple rows and the list of the products can change quite often.
Is there a better implementation to achieve the required result?