我很難讓我非常簡單的流星教程在Mongodb中讀取我的集合並打印到頁面上。這是流星網站上的官方tutuorial。任何幫助將非常感激。如果有人想連接到工作區並進行更改,請告訴我,我可以授予訪問權限。在MongoDB中使用流星
這裏是我的工作空間的鏈接:https://ide.c9.io/hilldesigns/meteor
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
tasks: function() {
return Tasks.find({});
}
});
}
下面是HTML標記:
<head>
<title>Todo List</title>
</head>
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li>{{text}}</li>
</template>
你的助手定義了「任務」,但你的模板使用「任務」。 –
我試過了,沒有成功@BrendanTurner – MontyTheMack
你不能附加一個模板助手這樣的身體。你必須製作一個模板(可能是'taskList')並通過{{> taskList}}包含它,然後將你的模板助手指向taskList而不是body。 –