我有以下路线:
this.route('groupPage', {
path: '/group/:_groupId',
waitOn: function(){
return Meteor.subscribe("groupPage", this.params._groupId);
},
data: function() {
var group = Groups.findOne({_id: this.params._groupId});
var members = Meteor.users.find({_id : {$in: group.memberIds}}); ******** ISSUE HERE******
return {
group: group,
members: members,
}; }});
和以下出版物:
Meteor.publishComposite('groupPage', function(groupId, sortOrder, limit) {
return {
// return the group
find: function() {
if(this.userId){
var selector = {_id: groupId};
var options = {limit: 1};
return Groups.find(selector, options);
}
else{
return ;
}
},
children: [
{ // return the members
find: function(group) {
var selector = {_id: {$in: group.memberIds} };
return Meteor.users.find(selector);
}
}
]}}) ;
现在我的问题是:当相关页面首先呈现时没有问题,但是当我实现组页面查看行时: var members = Meteor.users.find({_id : {$in: group.memberIds}} ); 给我错误:未定义的对象没有 memberIds 属性。我想这是因为在进行 group.memberIds 时订阅还没有准备好,不是吗?请提示。谢谢。