dimanche 6 mars 2016

How to display hasMany relationships in Ember 2.2 templates

Can't figure out why my related items aren't loading.

models/group.js

export default Model.extend({
    name: DS.attr('string'),
    slideshows: DS.hasMany('slideshow', { async: true }),
});

models/slideshow.js

export default Model.extend({
    title: DS.attr('string'),
    group: DS.belongsTo('group', { async: true }),
});

Main view:

{{#each groups as |group|}}
    {{slideshow-group group=group}}
{{/each}}

templates/components/slideshow-group.hbs

<li>
    <h2>{{group.name}}</h2>

    <ul>
        <li>{{group.slideshows}}</li>
        {{#each group.slideshows as |slideshow|}}
        <li>
            <h2>{{slideshow.title}}</h2>
        </li>
        {{/each}}
    </ul>
</li>

The first LI shows group.slideshows as DS.PromiseManyArray but the list is blank? Is it not loading them? How do I make it load them?




Aucun commentaire:

Enregistrer un commentaire