将对象绑定到 Select2 选项?

Bind object to Select2 option?

所以我有一个 Select2 表单:

<require from="./select2"></require>
<select select2="selected-values.two-way: selectedStuff" data-placeholder="Choose Stuff" multiple>
    <option repeat.for="thing of stuff">${thing.id}</option>
</select>

我可以用它访问 selectedStuff,它是所选 thingid 的数组。但是,我想取而代之的是获取 thing 本身的数组,而不是 id 的数组。在我的用例中,从 id 中查找 thing 是不可行的。有什么方法可以将 thing 对象绑定到 <option> 元素,以便我可以获得选定的 thing 数组而不是选定的 thing.id 数组?

<option> 元素的值属性只接受字符串。使用模型属性存储非字符串值:

<select select2 multiple value.bind="selectedThing2">
  <option repeat.for="thing of things" model.bind="thing">${thing.name}</option>
</select>

这是一个有效的 plunker:

http://plnkr.co/edit/mEpr8E?p=preview

这是关于 select 与 aurelia 绑定的文档:http://aurelia.io/docs.html#select-elements