ember.js - How get parent model from Ember-data -
i`m use ember-data 12 have 2 models, sideloads together:
app.store = ds.store.extend({ revision: 12, adapter: app.adapter.create() }); app.propose = ds.model.extend({ meeting: ds.belongsto('app.meeting'), time: ds.attr('string'), }); app.meeting = ds.model.extend({ name: ds.attr('string'), proposes: ds.hasmany('app.propose'), });
how me meeting propose model, example calculated field:
app.propose = ds.model.extend({ meeting: ds.belongsto('app.meeting'), time: ds.attr('string'), somecalc:function(){ this.get('meeting').get('name') //i want that. not worked } });
the way is:
app.propose = ds.model.extend({ meeting: ds.belongsto('app.meeting'), time: ds.attr('string'), somecalc:function(){ return this.get('meeting.name'); // or whatever operation need in here }.property('meeting.name') });
but ember data has evolved lot , not work (like this) in beta 2 , later.
Comments
Post a Comment