【发布时间】:2015-02-10 01:09:18
【问题描述】:
我有一个课程集
{courses{{course1_title,id,author,pages[{title,content,model, etc...},
[ etc...]{course2,....}}
我正在尝试通过路由器在课程集合中显示当前页面的数据
this.route('page', {
path: '/:title',
data: function() {
return courses.findOne({'pages.title':this.params.title};
}
});
我想这样显示当前页面的数据:
<template name="page">
<div class ="container page">
<h1>Page</h1>
<!--display current page data -->
<h3>{{title}}</h3>
<div>{{ an other content}} etc..... </div>
</div>
目前,路由器返回整个课程的数据,显示的标题是课程的标题。我没有找到如何访问当前页面的数据以便在页面的模板中显示它。
我试过了
return courses.findOne({'pages.title':this.params.title}{fields:{{'pages.title':this.params.title}:1}}
还有很多其他的方式。没找到。
什么是正确的方法?
【问题讨论】:
标签: mongodb meteor iron-router