【发布时间】:2015-11-25 16:10:41
【问题描述】:
我有一个小型列表构建应用程序,几乎是一个待办事项列表。
我有一个名为“列表”的集合
Lists = new Meteor.Collection('lists')
我有一个提交给这个集合的表单,它工作正常。
我的模板在这里:
<template name="list">
{{#with list}}
<ul>
{{#each links}}
<li>PLEASE WORK! >>>> {{title}}</li>
{{/each}}
</ul>
{{/with}}
</template>
我的助手在这里:
Template.list.helpers({
list: function () {
currentListId = Session.get('currentListId')
return Lists.find({
_id : currentListId
});
},
title: function () {
return this.title
}
})
我知道我订阅了数据库,因为当我订阅时:
Lists.find({_id : currentListId}).fetch()
它返回一个看起来像的对象
_id: "mrkpjGW2"
createdAt: 1447401698770
items: Array[3]
__proto__: Object
内部物品
items: Array[3]
0: Object
createdAt: 1447402263732
owner: "3oyKZKhdPZyDkWnZm"
title: "google.com"
__proto__: Objec
所以我想遍历项目,并获得标题。
【问题讨论】:
-
为什么不
{{#each items}}?
标签: javascript meteor meteor-blaze meteor-helper