I am using ember 2.8.0 and ember-data 2.8.0. I have the following models defined:
//app/models/store.js
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
floor: DS.belongsTo('floor'),
number: DS.attr('string'),
phone: DS.attr('string'),
email: DS.attr('string'),
photo: DS.attr(),
createdAt: DS.attr('date'),
updatedAt: DS.attr('date')
});
//app/models/floor.js
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
stores: DS.hasMany('store'),
createdAt: DS.attr('date'),
updatedAt: DS.attr('date')
});
My router.js has the following routes:
//app/router.js
this.route('stores', function() {
this.route('new');
this.route('edit');
});
My templates/stores/index.hbs has the following statement:
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
I would have expected that the line would have made a request to /floors/{id} for each and every row in the table.
What am I missing? What's the proper way to handle that in Ember?
Should my api return something different than the below?
[{"id":1,"floorId":1,"name":"McDonalds","number":"10-A","phone":"(11) 2020-3455","email":"lapa@mcdonalds.com.br","photo":null,"createdAt":"2016-09-15T13:45:32.000Z","updatedAt":"2016-09-15T13:45:32.000Z"}]
Should I use other model hooks to load the associated model manually?
Aucun commentaire:
Enregistrer un commentaire