我需要帮助来使用淘汰赛 foreach 绑定嵌套数组。
下面是代码,想知道如何获取 PatAppointments 数组中的元素。
<script language="javascript" type="text/javascript">
ko.applyBindings({
"appointment": [{
"Date": "01\/10\/2012",
"PatAppointments": [{
"EndTime": "11:15:00",
"EventId": null,
"Facility": "General Physician",
"PatientID": 23,
"PatientName": "Vicki"
}],
"PatAppointments": [{
"EndTime": "11:15:00",
"EventId": null,
"Facility": "General Physician",
"PatientID": 23,
"PatientName": "Scott"
}]
}]
});
</script>
<table>
<tbody data-bind="foreach: appointment">
<tr>
<td data-bind="text: Date">
</td>
</tr>
<tr>
<td>
@*
<tbody data-bind="foreach: appointment.PatAppointments">
<tr>
<td data-bind="text: PatAppointments.PatientName">
</td>
<td data-bind="text: PatAppointments.Facility">
</td>
</tr>
</tbody>
*@
</td>
</tr>
</tbody>
</table>