我在具有不同数据参数但使用相同出版物的其他路线中重用相同的模板...
如果我进行正常的发布/订阅,则数据将按预期发布。但是当我像下面那样进行有条件的发布/订阅时,我无法订阅数据。控制台日志返回空数组,,,
服务器/publication.js
Meteor.publish('ACStats', function(cId, uId) {
var selectors = {cId:cId, uId:uId};
var options = {
fields: {qId:0}
};
return ACStats.find(selectors,options);
});
客户端/onCreated
Template.channelList.onCreated(function() {
this.disable = new ReactiveVar('');
if (FlowRouter.getRouteName() === 'profile') {
var self = this;
self.autorun(function() {
var penName = FlowRouter.getParam('penName');
var u = Meteor.users.findOne({slugName:penName});
if (u) {var uId = u._id;}
Meteor.subscribe('ACStats', null, uId);
});
} else{
var self = this;
self.autorun(function() {
var channelName = FlowRouter.getParam('channel');
var c = Channels.findOne({title:channelName});
if (c) {var cId = c._id;}
Meteor.subscribe('ACStats', cId, null);
});
}
});
安慰
ACStats.find().fetch() //return empty array
有人发现我的错误..??
太感谢了....