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