如何将一个参数传递给带陨石铁路由器的Handlebars中的pathFor? [英] How to pass a parameter to pathFor in Handlebars for Iron-Router with Meteorite?

查看:78
本文介绍了如何将一个参数传递给带陨石铁路由器的Handlebars中的pathFor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带参数的简单路线:

  this.route('article',{
path :'/ article /:_ id',
data:function(){return Articles.findOne(this.params._id);}
});

我想在这里使用pathForForwardBars帮助器:_id:

  {{#each articles}} 
< li>< a href ={{pathFor'article'_id}}> ; {{TITLE}}< / A>< /锂>
{{/ each}}

这不适用于将_id标记传递到url虽然...

解决方案

< li>< a href ={ pathFor'article'_id = this._id}}> {{title}}< / a>< / li>

多数民众赞成你如何传递参数


I have a simple route with a parameter:

this.route('article', {
        path: '/article/:_id',
        data: function() { return Articles.findOne(this.params._id); }
    });

I would like to have use the pathFor handlebars helper here with the _id:

{{#each articles}}
<li><a href="{{pathFor 'article' _id}}">{{title}}</a></li>
{{/each}}

This doesnt work for passing the _id tag into the url though...

解决方案

<li><a href="{{pathFor 'article' _id=this._id }}">{{title}}</a></li>

Thats how you pass a parameter

这篇关于如何将一个参数传递给带陨石铁路由器的Handlebars中的pathFor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆