2014-02-12 74 views
3

我有這樣的選擇視圖從服務器加載的值:綁定Ember.select到

App.sectors = ["Alpinism", "Climbing", "Kayaking]; 

{{view Ember.Select contentBinding="App.sectors"}} 

現在,而不是固定值的向量,我想有填充值來自的選擇視圖服務器;換句話說,我想這樣做:

App.sectors = function() { 
    return this.store.find('sector'); 
} 

但這不起作用,因爲灰燼說我必須通過一個載體contentBinding而不是功能...

(我有部門模型定義:

App.Sector = DS.Model.extend({ 
    description: DS.attr('string') 
}); 

和我的寧靜服務器的答案正確就「域/部門」)

回答

2

的EmberData get請求範圍控制器上添加一個計算性能和回你來自那裏的真實數據。

App.IndexController = Em.Controller.extend({ 
    colors: function(){ 
    return this.get('store').find('color'); 
    }.property() 
}); 

http://emberjs.jsbin.com/OxIDiVU/199/edit

+0

太好了!非常感謝;) –

+2

你還可以告訴我如何設置Ember Select View的默認選定值嗎? –