Javascript 能够的不需要从集合中推送或弹出?这是一个数组。用户界面必须响应吗?这是一个可观察的展示。模型和视图模型在淘汰赛中模糊。不要担心遵循某种模式——这种模式的存在是为了服务于你,而不是反过来。我发现UI决定了什么是viewmodel-y,什么不是viewmode

Javascript 能够的不需要从集合中推送或弹出?这是一个数组。用户界面必须响应吗?这是一个可观察的展示。模型和视图模型在淘汰赛中模糊。不要担心遵循某种模式——这种模式的存在是为了服务于你,而不是反过来。我发现UI决定了什么是viewmodel-y,什么不是viewmode,javascript,mvvm,knockout.js,knockout-3.0,Javascript,Mvvm,Knockout.js,Knockout 3.0,能够的不需要从集合中推送或弹出?这是一个数组。用户界面必须响应吗?这是一个可观察的展示。模型和视图模型在淘汰赛中模糊。不要担心遵循某种模式——这种模式的存在是为了服务于你,而不是反过来。我发现UI决定了什么是viewmodel-y,什么不是viewmodel-y。如果我得到一个pojso,只需要在UI中显示它,它就是一个模型。如果它有一个需要交互绑定的属性,我将它转换为一个可观察的属性。不需要从集合中推送或弹出?这是一个数组。用户界面必须响应吗?这是耳环,谢谢!我决定直接绑定到model.sel


能够的不需要从集合中推送或弹出?这是一个数组。用户界面必须响应吗?这是一个可观察的展示。模型和视图模型在淘汰赛中模糊。不要担心遵循某种模式——这种模式的存在是为了服务于你,而不是反过来。我发现UI决定了什么是viewmodel-y,什么不是viewmodel-y。如果我得到一个pojso,只需要在UI中显示它,它就是一个模型。如果它有一个需要交互绑定的属性,我将它转换为一个可观察的属性。不需要从集合中推送或弹出?这是一个数组。用户界面必须响应吗?这是耳环,谢谢!我决定直接绑定到model.selectedLocation。谢谢!我决定直接绑定到model.selectedLocation。
self.selectedLocation = ko.pureComputed({
    read: function() {
        return self.model.selectedLocation();
    },
    write: function(value){
        self.model.selectedLocation(value);
    }
});
self.selectedLocation = self.model.selectedLocation;
var AppViewModel = function (screen1Vm, screen2Vm, ...) {
    var self = this;

    self.screen1ViewModel = screen1Vm;
    self.screen2ViewModel = screen2Vm;
    ...
}

var Screen1ViewModel = function () {
    var self = this;

    self.selectedLocation = ko.observable(null); //Initialize as null
    self.locations = ko.observableArray([]); //assuming they're selecting from a list of Location objects.  Initialize as empty array.
    ...
    //More logic to handle UI events, like a KO click event binding when one of the locations is selected, which is where self.selectedLocation would get set.  Something like this
    self.locationSelected = function (location) {
        //When bound to a control inside a KO foreach context, the actual object in the KO observable array will be passed in.
        self.selectedLocation(location);
    }
}

var Location = function (description, city, state, ...) {
    var self = this;

    self.description = ko.observable(description);
    self.city = ko.observable(city);
    self.state = ko.observable(state);
    ...
}

...

var screen1Vm = new Screen1ViewModel();
var screen2Vm = new Screen2ViewModel();
...
var myAppVm = new AppViewModel(screen1Vm, screen2Vm, ...)
ko.applyBindings(myAppVm);
<div data-bind="foreach: screen1ViewModel.locations">
    <!--Bind the click event to the viewmodel handler, and display the description of the location in the button-->
    <button data-bind="click: $parent.locationSelected"><span data-bind="text: description"></span></button>
</div>