【发布时间】:2016-03-26 16:01:50
【问题描述】:
我正在尝试让所有用户在我的主页模板上进行迭代,但我无法让它正常工作。我一直在尝试很多不同的技术,但这就是我现在所拥有的:
服务器:
Meteor.publish('userList', function() {
return Meteor.users.find({}, {fields: {username: 1, emails: 1, profile: 1}});
});
路由:
Router.route('/', {
name: 'home',
template: 'home',
waitOn: function() {
return Meteor.subscribe('userList');
},
data: function() {
return Meteor.users.find({});
}
});
HTML:
<template name="home">
<h1>Home page</h1>
{{#each userList}}
<p>Test</p>
{{userList.username}}
{{/each}}
</template>
我认为我的问题实际上在于 {{#each}} 块,因为我不知道该在那里调用什么。甚至没有显示测试文本。
【问题讨论】:
标签: javascript meteor iron-router publish-subscribe