Does Ember.js support model for app route?

In my Handelbar Ember Application template, I need some model data to display. In Index or other routes, these types of code work, but they don't work in the application route. 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 the problem is. In Ember, can you use a model for an app template?

+3


source to share


1 answer


Yes, definitely, the main reason your code won't work would be if you have an application controller installed that was not an ArrayController.



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

+3


source







All Articles