3

I have a select view like this:

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

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

Now instead of a vector of fixed values, i would like to have the select 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 doesn't work since Ember says i have to pass a vector to contentBinding and not a function...

(i have the sector model defined:

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

and my restful server answers correctly to the EmberData get request on 'domain/sectors')

Cereal Killer
  • 3,387
  • 10
  • 48
  • 80

1 Answers1

2

Add a computed property on 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

Kingpin2k
  • 47,277
  • 10
  • 78
  • 96