【发布时间】:2014-03-04 08:15:05
【问题描述】:
我无法在 gsp 页面的 foreach 中获取 observableArray 索引的最后一个,如下所示
<!-- ko foreach: $data.audienceInformation.IndivisualUsers -->
<span data-bind="html:$index()"></span> //Here index is coming correctly
<span data-bind="html:$last"></span> //i want last index here
<span data-bind="html:$data+','"></span>
<!-- /ko -->
这是我的 JSON 数据
{
"AccountMessagesHistory": {
"audienceInformation": {
"Accounts": ["DHL"],
"IndivisualUsers": ["fashangxue8@163.com"]
},
"documentInformation": ["Name: ",
"Title: <p>aa</p>",
"Description: <p>aa</p>",
"Document Type: text",
"This document belongs (creator/last modifier) to: b2b:cpqadmin@compaq.com",
"This document is published for the language: en_US",
"This document was created on: Mon Mar 03 03:15:09 MST 2014",
"This document was last modified on: Mon Mar 03 03:15:09 MST 2014",
"This document is a text document",
"This document will be available from: Mon Mar 03 00:00:00 MST 2014",
"This document will be available until: Tue Mar 03 00:00:00 MST 2015",
"This document is available under message feature card"],
"documentHistory": ["User ID: b2b:cpqadmin@xyz.com Name: HP Admin,ITG Modified On: Mon Mar 03 03:15:09 MST 2014"]
}
}
【问题讨论】:
-
您确定您使用的是淘汰赛 2.0.0 吗?我认为 $index 直到 2.1.0 才发布
标签: knockout.js knockout-2.0 knockout-mvc