【问题标题】:iron router add parameter to string as well as add a query铁路由器将参数添加到字符串以及添加查询
【发布时间】:2015-05-20 20:54:44
【问题描述】:

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

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

这是我尝试在 模板

中使用的链接
{{#each team.tags}}
   <a href="{{ pathFor 'team' _id:parent._id query...? }}">#{{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 

所以:

  1. 如何在模板中获取父团队_id?
  2. 如何在pathFor 中传递_id 和搜索参数?

提前致谢。

【问题讨论】:

    标签: javascript node.js meteor url-routing iron-router


    【解决方案1】:

    您可以使用../ 退回到父范围,在这种情况下似乎是teams

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

    【讨论】:

    • 谢谢。这就是传递团队 _id,那么传递搜索查询呢?
    • 还没来得及自己测试。看起来不错,我记得关于..的一些事情。
    猜你喜欢
    • 2016-01-01
    • 2011-02-11
    • 2015-09-04
    • 2019-08-01
    • 2012-05-31
    • 1970-01-01
    • 2016-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多