I have the following directive:
var productsTable = function() {
return {
restrict: 'E',
scope: {
products: '@'
},
templateUrl: '../js/app/templates/products_table.html'
};
};
The template is a simple table:
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="product in products track by $index">
<td><% product.id %></td>
<td><% product.name %></td>
<td><% product.quantity %></td>
</tr>
</tbody>
</table>
And it is used inside this piece of code:
<div ng-controller="MainController">
<div ng-repeat="entry in entries">
<products-table products="entry.products"></products-table>
</div>
</div>
An example of the entries
variable would be:
var entries = [
{
id: 1,
products: [
{
id: 1001,
name: 'Product 1',
quantity: 30
},
{
id: 1002,
name: 'Product 2',
quantity: 3
}
]
},
{
id: 2,
products: [
{
id: 3001,
name: 'Product 3',
quantity: 450
}
]
}
];
The problem is: the directive does not recognize the products array, and does not show the table.