I am trying to set up a simple platform for employees to give feedback to each other. I am using ember-data (from beta branch).
Models:
App.Employee = DS.Model.extend({
name: DS.attr()
})
App.Feedback = DS.Model.extend({
text: DS.attr(),
employee: DS.belongsTo('employee', {async: true})
})
Router (simplyfied):
App.Router.map(function(){
this.resource('profile', {path: 'profile/profile_id'})
})
App.ProfileRoute = Ember.Route.extend({
model: function(params){
return this.store.find('employee', params.profile_id);
}
})
Data:
App.Employee.reopenClass({
FIXTURES: [
{ id: 1, name: 'Trek'},
{ id: 2, name: 'Tom'}
]
});
App.Feedback.reopenClass({
FIXTURES: [
{ id: 1, text: 'Topic1', employee: 1},
{ id: 2, text: 'Topic2', employee: 2},
{ id: 3, text: 'Topic3', employee: 1},
{ id: 4, text: 'Topic4', employee: 2}
]
});
I can't get a list of feedbacks to display in the template profile
.
Template:
{{#each feedback in model.feedback}}
{{feedback.text}}
{{/each}}
I can't figure out, what I'm doing wrong.
Should I specify feedbacks: DS.hasMany('feedback')
under App.Employee
? Or should I do this through the controller?
Aucun commentaire:
Enregistrer un commentaire