KnockoutJS を使用してテーブルにバインドしたい JavaScript オブジェクトがあります。
ここに私のオブジェクトがあります:
var data = {
"Warnings": {
"numbers": 30,
"content": [
{
"number" : 3001,
"description" : "There may be a problem with the device you are using if you use the default profile"
},
{
"number" : 3002,
"description" : "There may be a problem with the device you are using if you don't use the default profile"
}
]
},
"Errors": {
"numbers": 20,
"content": [
{
"number": 1000,
"description": "No network is loaded"
},
{
"number": 1000,
"description": "No network is loaded"
}
]
}
};
ko.applyBindings(data);
これが私のhtmlコードです:
<table class="table table-hover">
<thead>
<tr>
<th style="width:100px">Numero</th>
<th>Description</th>
</tr>
</thead>
<tbody data-bind="foreach: Warnings.content">
<tr data-bind="foreach: $data">
<td data-bind="text: $data.number"></td>
<td data-bind="text: $data.description"></td>
</tr>
</tbody>
</table>
ここに JSFiddle があります: http://jsfiddle.net/etiennenoel/KmKEB/
データ オブジェクトにこの形式を使用する必要があります。
エラーが発生していないため、警告が表にリストされていない理由がわかりません...