【问题标题】:Using current each data inside a query in pathFor iron-router在 pathFor Iron-router 的查询中使用当前的每个数据
【发布时间】:2015-03-19 21:43:31
【问题描述】:

刚开始玩流星,我正在尝试使用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,我怎样才能使它工作?

【问题讨论】:

    标签: javascript node.js meteor url-routing


    【解决方案1】:

    因为它是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,因为空格键不允许复合操作。

    【讨论】:

      猜你喜欢
      • 2014-12-15
      • 1970-01-01
      • 2016-03-25
      • 1970-01-01
      • 2015-11-01
      • 2015-12-16
      • 1970-01-01
      • 1970-01-01
      • 2015-08-24
      相关资源
      最近更新 更多