I have this code:
<select name="test" id="test" class=""
data-bind="
options: myArray,
value: idSelected,
optionsText: 'name',
optionsValue: 'id',
optionsCaption: 'All'>
</select>
Result:
text 1
text 2
text 3
...
I want concat Id and name with '-' . I want this:
1 - Text 1
2 - text 2
3 - text 3
...
You can create a
computed
property and bind that tooptions
.Here's a working snippet:
(You can also use
pureComputed
if you're using knockout 3.2+)