knockout-postbox syncwith不使用可观察数组

时间:2015-08-04 18:46:27

标签: javascript knockout.js knockout-postbox

我有以下视图模型。在视图模型一中我也有一些代码将记录添加到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 }
});

0 个答案:

没有答案