Hasib Mahmud
Hasib Mahmud

Reputation: 786

Do Ember.js support model for Application route?

In my Ember Application Handlebars template, I need some model data to display. In Index or other routes, these types of code work but in application route they are not working. Application Route:

App.ApplicationRoute = Ember.Route.extend({
 model: function()
 {
  return this.store.findAll('archive');
 }
});

Application template:

<script type="text/x-handlebars" data-template-name="application">
 {{#each}}
  {{title}}
 {{/each}}
</script>

DS.Model:

App.ApplicationAdapter = DS.FixtureAdapter;

App.Archive = DS.Model.extend({
  title: DS.attr('string'),
  day:   DS.attr('number')
});

App.Archive.FIXTURES = [
 {
  "id":1,
  "title": "First title",
  "day": 06
 },
 {
  "id":2,
  "title": "Second title",
  "day": 08
 }
];

I couldn't find out where is the prob. In Ember, can I use model for Application template?

Upvotes: 3

Views: 804

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Yes definitely, the main reason your code wouldn't be working would be if you have an application controller defined that wasn't an ArrayController.

Example: http://emberjs.jsbin.com/OxIDiVU/1115/edit

Upvotes: 3

Related Questions