selected object pattern with knockout
问题 Does anybody know how I'd accomplish the following pattern with knockoutJS? I use this pattern all the time in apache flex and want to see if I can mimic it. I am unsure how to replace an observable with another. Any help/thoughts much appreciated. //model myViewModel = { items : ko.observableArray(), selected_item : ko.observable() } //view <h3 data-bind="text : myViewModel.selected_item.name"> </h3> <ul> <!-- ko foreach: myViewModel.items --> <li data-bind="text : name"/> <!-- /ko --> </ul>