【发布时间】:2015-12-11 22:06:07
【问题描述】:
我在 server/publications.js 中有以下内容...
Meteor.publish("users", function(){
return Meteor.users.find({}, {fields: {profile: 1}});
});
...在我的铁路由路由...
Router.route('/', function() {
this.layout('ConfLayout');
this.render('UserList', {
waitOn: function () {
return Meteor.subscribe("users");
},
data: function () {
return {
users: function () {
return Meteor.users.find();
}
};
}
});
});
...然后在我的模板中....
<template name="UserList">
<h1>Users</h1>
<ul>
{{#each users}}
<li>
{{#linkTo route='user.show'}}
<div>
{{profile.lastName}}, {{profile.firstName}}
</div>
{{/linkTo}}
</li>
{{/each}}
</ul>
</template>
...除了客户端上唯一的用户是当前登录的用户之外,它有点工作。我正在尝试为管理员获取所有用户的列表(暂时不要担心管理员部分)。
同样奇怪的是,我在发布函数中添加了一个 console.log 语句,它永远不会被记录。但是,同一文件中的所有其他出版物似乎都可以正常工作。此外,如果我启用自动发布,那么所有用户都会按预期显示。
我在这里错过了什么?根据我能找到的所有内容,发布特定字段似乎应该适用于在客户端显示所有用户,但似乎 Meteor 似乎完全忽略了 Meteor.users 上的任何出版物。我正在使用 Meteor 1.1.0.3。
任何想法或帮助表示赞赏!
TIA
【问题讨论】:
标签: meteor iron-router