我有以下视图模型。在视图模型一中我也有一些代码将记录添加到accountList。当我尝试在viewmodel中使用accountList时,它总是为空。不应该使syncWith保持这两个observableArrays同步吗?
ViewModel one
define(['knockout', 'text!./eligible.html', 'kendo'
, 'toastr'
, 'Scripts/App/models/m_accountslist'
, 'Scripts/App/constants/cont'
, 'postbox'
], function (ko, eligible, k, toastr, model, cont) {
function eligibleViewModel(params) {
var self = this;
self.accountList = ko.observableArray().syncWith("accountList", true,false)
return self;
}
return { viewModel: eligibleViewModel, template: eligible }
})
查看模型二
define(['knockout', 'text!./offermodal.html'
, 'toastr'
, 'Scripts/App/models/m_accountslist'
, 'komapping'
, 'Scripts/App/constants/cont'
, 'postbox'], function (ko, offermodal, toastr, model, komapping,cont) {
var offermodalViewModel = function() {
var self = this;
self.accountList = ko.observableArray().syncWith("accountList",true,false)
return self;
}
return { viewModel: offermodalViewModel, template: offermodal }
});