0

我有以下视图模型。在视图模型一中,我还有一些将记录添加到 accountList 的代码。然后当我尝试在视图模型二中使用 accountList 时,它总是空的。syncWith 不应该让这两个 observableArrays 保持同步吗?

视图模型一

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 }
});
4

0 回答 0