流星模板助手功能无法正常工作

时间:2016-02-28 00:00:25

标签: meteor iron-router

我在Template.meetings.helpers中有2个函数,但只有一个函数正在运行。

Template.meetings.helpers({
  group: function() {
    console.log('meeting id from helper group = ' + this.meetingId);
    console.log('group id from helper group = ' + this.groupId);
    return Groups.findOne({_id: this.groupId});
  },
  meeting: function() {
    console.log('meeting id from helper meeting = ' + this.meetingId);
    console.log('group id from helper meeting = ' + this.groupId);
    return Meetings.findOne({_id: this.meetingId});
  },
});

我的控制台显示以下内容:

router.js:73 meetingId from router = ZKkLLvdCpRmrF7uXD
router.js:74 groupId from router = xFSzAHBEps2dSKcWM
meetings.js:26 meeting id from helper meeting = ZKkLLvdCpRmrF7uXD
meetings.js:27 group id from helper meeting = xFSzAHBEps2dSKcWM

router.js:

Router.route('/meetings/:_id/:groupId?', {
	waitOn: function() {
    return Meteor.subscribe('meeting');
    return Meteor.subscribe('Group');
  },

	action: function () {
    console.log('meetingId from router = ' + this.params._id);
    console.log('groupId from router = ' + this.params.groupId);
	  this.render('meetings', {
			data: {
        meetingId: this.params._id,
        groupId: this.params.groupId
			}
		});
	},
  onBeforeAction: function(){
		var currentGroup = Members.find({
      groupId: this.params.groupId,
      memberId: Meteor.userId()
    }).count();
    Session.set('groupId', this.params.groupId);
    var currentUser = Meteor.userId();
    if(currentUser && currentGroup > 0){
        this.next();
    } else {
        this.render("landingPage");
    }
  }
});

我无法弄清楚为什么group:function()没有输出到控制台。

有什么建议吗?

0 个答案:

没有答案