Iam not able to display product items with Knockout.js library.
Html
<p>First product: <strong data-bind="text: products[0].description"></strong></p>
<tbody data-bind="foreach: products">
<tr>
<td data-bind="text: id"></td>
<td data-bind="text: description"></td>
</tr>
</tbody>
JavaScript
<script type='text/javascript'>
$(function () {
var json = {
"products": [
{ "id": 1, "description": "product A" },
{ "id": 2, "description": "product B" },
{ "id": 3, "description": "product C" }
]
}
function viewModel() {
this.products = json.products;
}
ko.applyBindings(new viewModel());
});
</script>
I do not get any error message, but i see only "First product:" text. What am I missing ?