我尝试从博客列表链接到博客详细信息页面,但该链接不起作用。我在这里做错了什么?链接中的 this._id 是正确的 id。 这是我的路线
this.route('blogdetail', {
path: '/groupsmain/:_id/blogs/:paramOne',
template:'groupdetail',
yieldTemplates: {
'blogdetail': {to: 'dynamiccontent'}
},
controller: blogdetailController
});
博客列表的网址是
http://localhost:3000/groupsmain/NQxvBfeNQE875HDRR/blogs
这是我的博客详细信息链接
<h3><a href="{{pathFor 'blogdetail' paramOne=this._id}}">{{this.title}}</a></h3>
最佳答案
pathFor
从当前数据上下文中获取参数,而不是从传递给它的参数中获取参数。因此,您需要使用 #with
帮助器更改上下文:
<a href="{{#with _id=_id paramOne=this._id}}{{pathFor 'blogDetail'}}{{/with}}">
关于meteor - 从模板传递meteor.js中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25608066/