vendredi 30 octobre 2015

Why does data from a model not render in an Ember template's {{#each}} loop?

Data that seems successfully loaded into my model does not seem to be used when rendering a page template in Ember 2.1.0. How can I get the data that is shown to me in Ember Inspector to be successfully called by the page template?

I have a model:

  App.Part = DS.Model.extend({
    name: DS.attr('string'),
    summary: DS.attr('string')
  });

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

and a template:

{{appName}} v {{appVersion}}
<ul>
  {{#each part in model}}
        <li>{{part.name}}</li>
    {{else}}
        none found...
  {{/each}}
</ul>

and in my Ember Inspector I see data (loaded via RESTAdapter): Data properly loaded loaded with unique IDs and part names

But the template when rendered always says, "none found..." and never lists the data that appears to have been successfully loaded. I have tried multiple variations of the {{#each}} tag.

A standard app controller loads data into the template just fine (calling {{appName}} or {{appVersion}}):

App.ApplicationController = Ember.Controller.extend({
  appName: "My App",
  appVersion: "1.0",
});

Ember 2.1.0, EmberData 2.1.0, EmberInspector 1.9.3




Aucun commentaire:

Enregistrer un commentaire