Bind Ember. Select values ​​downloaded from the server.

I have a similar choice:

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

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

Now, instead of a vector of fixed values, I would like to have a selection view populated with values ​​coming from the server; in other words, I would like to do something like:

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

but this will not work, since Ember says that I need to pass the vector to the contentBinding, not to the function ...

(I have a sector model defined:

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

and my calm server responds correctly to the request for EmberData in the domain / sectors.

+3
source share
1 answer

Add the calculated property to the controller in scope and return your real data from there.

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

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

+2
source

All Articles