我需要将url参数连接到锚标记上。我该如何将其插入以下模板?
<tbody data-bind="foreach: Customers">
<tr class="rowEven">
<td data-bind="text: Name"></td>
<td data-bind="text: CustomerType"></td>
<td><a href="customers.aspx?customer=[CustomerAccountIDHere]">Manage</a><a href="#">Guest Admin</a></td>
</tr>
</tbody>
我试过这不会运气:
<tr class="rowEven">
<td data-bind="text: Name"></td>
<td data-bind="text: CustomerType"></td>
<td><a data-bind="attr: { href: 'customers.aspx?customer=' + CustomerAccount_BID}">Manage</a><a href="#">Guest Admin</a></td>
</tr>
答案 0 :(得分:14)
我认为viewmodel可能是问题,这是一个有效的例子:http://jsfiddle.net/L4hUq
答案 1 :(得分:9)
添加“()” - CustomerAccount_BID()适合我。
答案 2 :(得分:0)
尝试这样的事情......
$(function()
{
var myViewModel1 = function () {
var self = this;
self.firstName = ko.observable("Kamalakar");
self.lastName = ko.observable("Ashtankar");
self.fullName = ko.pureComputed(function () {
return self.firstName() + " " + self.lastName();
}
);
};
ko.applyBindings(myViewModel1);
});