2013-07-23 145 views
3

我真的父模型使用燼數據12 我有2個車型,其中一起側向載荷:如何從灰燼數據

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'), 


}); 

我如何從提出模型滿足,例如一些計算領域:

App.Propose = DS.Model.extend({ 
     meeting: DS.belongsTo('App.Meeting'), 
     time: DS.attr('string'), 
     someCalc:function(){ 
      this.get('meeting').get('name') //I want that. but its not worked 
     } 
    }); 
+0

你能不能讓一個jsfiddle顯示這個問題? – ThomasDurin

+0

非常過時的使用了餘燼數據 –

回答

0

你會做到這一點的方法是:

App.Propose = DS.Model.extend({ 
    meeting: DS.belongsTo('App.Meeting'), 
    time: DS.attr('string'), 
    someCalc:function(){ 
     return this.get('meeting.name'); // or do whatever operation you need in here 
    }.property('meeting.name') 
}); 

但灰燼數據已經進化了很多,THI在Beta 2及更高版本中,它不會起作用(像這樣)。