2
我刚接触Javascript和流星 - 我敢肯定我犯了一个非常基本的错误。开始使用流星 - 显示集合
我想了解如何显示集合的内容。
这是基于对流星网站上的教程 - 我已经替换为“任务”“SW”这也是我收藏的名称
Template.HomePrivate.helpers({
});
sw = new Mongo.Collection("sw");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
text: function() {
return sw.find({});
}
});
}
HTML:
<template name="HomePrivate">
<div class="page-container container" id="content">
<div class="row" id="title_row">
<div class="col-md-12">
<h2 id="page_title" class="pull-left">
Welcome {{userFullName}}!
</h2>
<div id="page_menu" class="pull-right">
</div>
</div>
</div>
</div>
<div class="container">
<header>
<h1>Sight Words</h1>
</header>
<p>begin list</p>
<ul>
{{#each sw}}
{{> sw}}
{{/each}}
</ul>
<p>end list</p>
</div>
</template>
<template name="sw">
<li>{{text}}</li>
</template>