我想使用这种技术将包含许多字段的非常大的对象映射到javascript对象中:
var viewModel = ko.mapping.fromJS(data);
但是,我还希望能够向viewModel添加其他属性/功能。怎么做?
编辑 - 这是答案:
这个问题的答案如下:
function MyModelOject(data) {
var self = this;
ko.mapping.fromJS(data, {}, this);
// other functions go here
}
答案 0 :(得分:2)
function MyModelOject(data) {
var self = this;
ko.mapping.fromJS(data, {}, this);
// other functions go here
}