0
我有一個JavaScript對象,我想用KnockoutJS與對象淘汰賽表綁定
這裏綁定到一個表是我的對象:
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/
我真的需要使用這種格式爲我的數據對象。
我不知道爲什麼我沒有在表中列出,因爲我沒有得到任何錯誤的警告......
這是[工作小提琴](http://jsfiddle.net/Tre2U/) –
這是一個愚蠢的錯誤,謝謝! – CoachNono