2014-10-07 111 views
0

我有一個獲取公司員工列表的路線模型。員工模型與用戶模型關聯,用戶模型具有員工姓名。要顯示列表員工姓名我做這個模型和模板:在選擇中顯示用戶名稱

return this.modelFor('management').get('employees'); 

{{#each}} 
    {{render "employee" user}} 
{{/each}} 

如果用戶是用戶ID和員工模板只顯示{{全名}}。

我想知道如何將全名綁定到一個下拉列表,其中的值將來自Employee id,(工作),但來自關聯用戶的全名將顯示在Select框。

回答

0

使用灰燼選擇視圖:

{{view Ember.Select 
    content=controller.employees 
    optionLabelPath="content.user.displayName" 
    optionValuePath="content.employeeId" 
    value=selectedEmployee 
}} 

optionLabelPath設置爲每個選項標籤(顯示器),及optionValuePath套什麼所選擇的選項的值將被設定爲value屬性。

JSBin