我正在尝试计算视图模型中的第三个字段。我知道这不是方法,但只是给出了以下代码片段。请帮忙
$.ajax({
type: "GET",
url: '/ASPNET/GetGroups',
dataType: "json",
success: function (data) {
var viewModel = {
advisorGroup: ko.observableArray(data)
};
viewModel.advisorGroup.label = ko.computed(function () {
return self.code + ' (' + self.cls+')';
});
alert(JSON.stringify(viewModel));
ko.applyBindings(viewModel);
}
})
<input type="checkbox" data-bind="attr: { value: code, id: code }" name="GroupsSel" checked="checked">
<label data-bind="attr: { for: code }, text: label "></label>