似乎我无法在我的助手中访问 FlowRouter 模板订阅。你怎么能做到这一点?
在我的服务器代码中:
Meteor.publish('AllUsers', function() {
return Meteor.users.find({}, {fields: {profile: 1}});
})
在我的路由器代码中:
var userRoutes = FlowRouter.group({
subscriptions: function(params, queryParams) {
this.register('AllUsers', Meteor.subscribe('AllUsers'));
},
});
在我的模板代码中:
{{#if checkFlowRouterSubs}}
{{#each getTheUsers}}
{{>userPartial}}
{{/each}}
{{/if}}
在我的助手中,我有“警卫”:
checkFlowRouterSubs: function() {
if (FlowRouter.subsReady()) {
return true;
};
return false;
},
然后是 getTheUsers 助手:
...
var users = AllUsers.find(filterObject, { sort: { 'profile.firstname': 1 } }).fetch(); // the actual query definitely works
...
但我收到一个错误:
Exception in template helper: ReferenceError: AllUsers is not defined
我应该注意,在 getTheUsers 帮助器中,FlowRouter.subsReady('AllUsers')
返回 true