vendredi 12 mai 2017

Ember Data Filtering

I am having trouble outputting one to many Ember data. The data is getting loaded into Ember Data properly per the developer tools tab. But I'm unable to access the categories for some reason.

game model

//app/models/game.js
import DS from 'ember-data';

export default DS.Model.extend({
    gameCategory: DS.belongsTo('game-category'),
    gameName: DS.attr('string'),
});

gameCategory model

//app/models/game-category.js
import DS from 'ember-data';

export default DS.Model.extend({
    gameCategory: DS.attr('string'),
    games: DS.hasMany('games')
});

The JSON returned to model.gameCategory

{"game":
    [
      {"id":1,"gameName":"Monopoly","gameCategory":"Board Games"},
      {"id":2,"gameName":"Chess","gameCategory":"Board Games"},
      {"id":3,"gameName":"Zelda","gameCategory":"Video Games"},
      {"id":4,"gameName":"Mario","gameCategory":"Video Games"}
    ],
 "gameCategory":
    [
      {"id":"Board Games", "gameCategory": "Board Games", "games": [1, 2]},
      {"id":"Video Games", "gameCategory": "Video Games", "games": [3, 4]}
    ]
}

Template

//app/templates/games.hbs

    <div class="cat">
    
        <div class="game"></div>
    
    </div>





Aucun commentaire:

Enregistrer un commentaire