0
我想讓所有的用戶都在我的主頁模板上迭代,但我有麻煩讓它工作。我一直這麼多不同的技術,但是這是我現在得到:如何迭代流星模板中的所有現有用戶?
服務器:
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}}
區塊,因爲我不知道該在那裏打電話。甚至不顯示測試文本。
這工作, 非常感謝! –