meteor - 从模板传递meteor.js中的参数

标签 meteor iron-router

我尝试从博客列表链接到博客详细信息页面,但该链接不起作用。我在这里做错了什么?链接中的 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/

相关文章:

javascript - 如何通过 Meteor 中的隐藏字段将 _id 传递给 autoForm?

node.js - 在 Docker 中构建 Meteor 无法通过代理设置

Meteor 帐户电子邮件验证失败有两种方式

javascript - 铁路由器与流路由器

node.js - Meteor MongoDB 订阅以 10 秒的间隔而不是实时传递数据

deployment - 为什么命令 'meteor deploy'会上传这么多数据?

meteor - 免费 meteor 服务器的规范是什么?

meteor - Iron 路由器子布局 - 获取产量数据上下文

meteor - flow-routing中iron-routing的 ‘pathFor’函数的替换函数是哪个函数?

javascript - 在 Iron Router 中使用布局时向 <head> 添加行