我试图通过单击显示“查看更多”的链接将我的#each 项目循环中的单个记录打开到它自己的视图中,这将带我进入单个文章。我设置了我的 Flow 路由器及其工作,但我看不到应该进入的数据。
单篇文章的模板助手看起来像这样
Template.collectionSingle.helpers({
articles: function () {
var id = FlowRouter.getParam('_id')
return theCollection.findOne({_id: id});
}
});
}
我的路线看起来像这样
FlowRouter.route('/collection/:_id', {
name: 'collection',
action() {
BlazeLayout.render("AppLayout", {main: "collectionSingle"});
}
});
模板“collectionSingle”看起来像这样
<template name="collectionSingle">
<h1>{{title}}</h1>
<h1>This is a test</h1>
<img src="{{thumbnail}}" alt="" />
</template>
当我导航到http://localhost:3000/collection/thePublication-0时 ,我看到的只是测试消息“这是一个测试”,但我没有看到 {{title}} 也没有缩略图。
此外,当我改变时:
return theCollection.findOne({_id: id});
到我的另一个收藏:
return OtherCollection.findOne({_id: id});
http://localhost:3000/collection/thePublication-0
保持不变。
我怎样才能成功地为我的每篇文章创建一个单独的文章页面,并将它们与流路由器正确链接?