javascript - 在 pathFor iron-router 中的查询中使用当前每个数据

标签 javascript node.js meteor url-routing

刚开始玩meteor,我正在尝试使用iron-router 进行路由。这是我的数据结构:

team
  _id
  name
  tags:[{name,counter}]

这是我尝试在模板中使用的链接

{{#each team.tags}}
   <a href="{{ pathFor 'team' _id=../team._id query='search='+this.name }}">{{this.name}} <span class="count-list">{{this.counter}}</span></a> 
{{/each}}

我的路由器有:

route('/team/:_id')  // And I get the search through the GET property... this.params.query 

但它不喜欢 query='search='+this.name,我该如何使其工作?

最佳答案

因为它是一个 GET 方法,所以这应该有效:

{{#each team.tags}}
   <a href="{{ pathFor 'team' _id=../team._id}}/?search={{this.name}}">{{this.name}} <span class="count-list">{{this.counter}}</span></a> 
{{/each}}

否则,您必须在预先的帮助程序(或 registerHelper 函数)中构建 URL,因为空格键不允许复合操作。

关于javascript - 在 pathFor iron-router 中的查询中使用当前每个数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29155555/

相关文章:

javascript - Highcharts 突出显示两条线之间的区域

javascript - 在 Node-FFI 中使用 SendInput

javascript - Meteor:如何确保在进入 Router.go 之前从方法中更新新的 session 变量?

node.js - 类型错误 : Cannot call method 'get' of undefined

javascript - guilds.verificationLevel 无法正确执行自定义输出

meteor - 无法下载 "https://github.com/sass/node- sass/releases/download/v4.5.2/darwin-x64-57_binding.node"错误。这是什么意思?

javascript - MeteorJS 集合未定义

javascript - 在我的 ASP CMS 中找不到此错误的原因

c# - JQuery - 用 <li> 替换 html 按钮,同时保持值不变

node.js - 通过 UNC 路径使用 fs 在 Node 中读取/写入文件