1
我想要返回我的余烬控制器中的关联对象的计数。在ember.js中计数嵌套关联对象
我:
App.Comment = DS.Model.extend({
discussion: DS.belongsTo('App.Discussion')
});
App.Discussion = DS.Model.extend({
meeting: DS.belongsTo('App.Meeting'),
comments: DS.hasMany('App.Comment')
});
App.Meeting = DS.Model.extend({
discussions: DS.hasMany('App.Discussion')
});
现在在我的会议控制器我想返回计数与会议相关的讨论和评论:
App.MeetingController = Ember.ObjectController.extend({
discussionCount: function(){
return this.get('discussions.length');
}.property('discussions')
});
我能得到的讨论很好,但我可以没有办法获得与每次会议相关的讨论的相关评论。任何想法如何最好做到这一点?
你不应该需要转换你的'ManyArray' App.MeetingController = Ember.ObjectController.extend({ discussionCount:函数(){ 回报this.get( 'discussions.length');} .property ('讨论') }); – 2013-04-29 22:51:24
谢谢,我将编辑示例。任何帮助嵌套关联? – i0n 2013-04-29 23:06:19
测试的东西;-) – 2013-04-29 23:15:43