我想在我的模板中显示所有用户的列表。 我有:流星:发布所有用户不工作,没有自动发布包
//publications.js
Meteor.publish('users', function() {
return Meteor.users.find({}, { fields: {username: 1, profile: 1} });
});
//router.js
Router.route('/users/add/:_id?', {name: 'users.add', controller: 'UserAddController'});
UserAddController = RouteController.extend({
subscriptions: function(){
return [ Meteor.subscribe('hospitals'),
Meteor.subscribe('roles'),
Meteor.subscribe('users') ];
},
action: function() {
this.render('addUser', {
data: function(){
return { hospital_id : this.params._id }
}
});
}
});
//client
Template.listUsers.helpers({
users: function() {
return Meteor.users.find({});
}
});
但该列表只显示当前登录的用户。我创建了一个使用Account.createUser()
函数的用户列表我做错了什么?
谢谢。
您的publications.js文件位于何处?它应该在服务器目录中。 –
是的,它在服务器目录中。 –
检查您的模板。还要在浏览器控制台中执行'Meteor.users.find()。fetch()',看它是否包含所有用户。 –