Shall I get any sample to place the Dropdown List in for each of ko databind.something like give below
<div data-bind="foreach:valuelist>
<select data-bind ="options :valuelist value =selecteditem></select>
</div>
有这样的样品吗?
Shall I get any sample to place the Dropdown List in for each of ko databind.something like give below
<div data-bind="foreach:valuelist>
<select data-bind ="options :valuelist value =selecteditem></select>
</div>
有这样的样品吗?
我在 jsFiddle 中创建了一些示例单击此处查看示例。
所以一般来说,你应该做以下事情:
1. 例如创建一些带有名称值的 observableArray:
self.values = ko.observableArray([ "Item 1", "Item 2", "Item 3", "Item 4"]);
2.像这样添加你的html:
<div data-bind="template: { name: 'myTemplate', foreach: values}">
</div>
<script id="myTemplate" type="text/html">
<select data-bind="options: $root.values, optionsCaption: 'Choose..'"></select>
</script>
希望它会帮助你。