Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor Iron路由器通过arraylist值作为参数_Meteor_Router_Query Parameters - Fatal编程技术网

Meteor Iron路由器通过arraylist值作为参数

Meteor Iron路由器通过arraylist值作为参数,meteor,router,query-parameters,Meteor,Router,Query Parameters,我是meteor的新手,一直在尝试将值从arraylist传递到href pathfor元素 我有一个模板 <template name="Listing"> {{#each data}} <a href="{{pathFor 'listingbycompanyL1' this}}">{{this}}</a><br/> {{/each}} <a href="javascript:history.back()">Bac

我是meteor的新手,一直在尝试将值从arraylist传递到href pathfor元素

我有一个模板

<template name="Listing">
  {{#each data}}
    <a href="{{pathFor 'listingbycompanyL1' this}}">{{this}}</a><br/>
  {{/each}}
  <a href="javascript:history.back()">Back</a>
</template>
它将以字符串列表的形式返回一些数据。例如,当打印到控制台时,我将获得

Listing.helpers : distinct listings : a,b,c
我想

  • 将我收到的值作为参数发送到Iron Router,以便我可以使用该值进行集合搜索
  • 我的路由器配置如下:

    this.route("listingbycompanyL1",{
      path:"/listingL1",
      layoutTemplate: 'ListingbycompanyL1',
      data: function(){
        var update=MyCustomCollection.find({orgName:"XXXX" }).fetch();
        return {
          update:update
        };
      }
    });
    

    如何将接收到的值(a、b、c)传递给IR并使用它进行搜索,其中XXXX是a或b或c

    this.route("listingbycompanyL1",{
      // specify the strategy _id as an URL component instead of query parameter
      path:"/listingL1/:a",
      layoutTemplate: 'ListingbycompanyL1',
      data: function(){
        var update=MyCustomCollection.find({orgName: this.params.a }).fetch();
        return {
          update:update
        };
      }
    });
    

    不清楚你想在路由器上做什么。路由器代码中的注释表示您试图避免使用查询参数。与此同时,您的路由器正在尝试查找与
    a、b、c
    无关的
    orgname:“XXXX”
    a、b、c
    总是三元组还是可以是元组、四元组或任何数字?您是否考虑过在模板助手中设置会话变量(或反应变量)并从路由中引用它。谢谢您的评论。基本上,我正在使用模板中的#每个成功创建HREF。现在我想将href的值传递给IR,以便可以使用此值查询我的集合。备注:IR中的评论有误导性,已删除。谢谢,如何创建href
    示例:
    {{pathFor'article'\u id=this.\u id}}
    谢谢,我更新了以下
    和IR到
    路径:'/listingL1/:\u id'
    ,但这似乎不起作用,我的链接无法点击,这意味着路径创建不正确。我还尝试了以下
    注意,MyCompanyName这里是我想要动态发送的值,在IR中,我可以在IR
    console.log(this.params.query.company)中看到这个参数缺少的部分..如何将{{this}}的值发送到mycompanynamehere.还要注意,最初发送的数据没有id,它是一个字符串列表,我正在模板中迭代,我想将该字符串值进一步发送到IR,以便我可以对我的集合进行搜索。非常感谢您的帮助,我仍然是一个新手。我很抱歉,自从前面的堆栈溢出问题以来,ir显然发生了变化。
    
    this.route("listingbycompanyL1",{
      // specify the strategy _id as an URL component instead of query parameter
      path:"/listingL1/:a",
      layoutTemplate: 'ListingbycompanyL1',
      data: function(){
        var update=MyCustomCollection.find({orgName: this.params.a }).fetch();
        return {
          update:update
        };
      }
    });