This is a pretty basic, but for some reason I can't get it working.
I've created a companies resource:
App.Router.map(function() {
this.resource('companies');
});
and specified a model
App.Company = DS.Model.extend({
name: DS.attr('string'),
});
App.CompaniesRoute = Ember.Route.extend({
model: function() {
return App.Company.find();
}
});
I have some Fixtures for test data.
Now, shouldn't I have access to my companies
data from the controller? Like this
App.CompaniesController = Ember.ArrayController.extend({
length: function () {
return this.get('length');
}.property(),
});
I'm getting 0, and everything I've tried in this function makes me think somehow the controller isn't getting loaded with the data - even though I am able to loop through the models in my template, like this:
<script type="text/x-handlebars" data-template-name="companies">
<div class="row">
<div class="span12">
<h3>Companies</h3>
{{#each controller}}
<li>{{ name }}</li>
{{/each}}
</ul>
</div>
</div>
</script>
Some parts of the docs show setupController instead of model: function() {}
, but I'm not clear about the differences. I've tried both, to no success.
Any ideas?