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

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

问题描述

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

I have a simple route with a parameter:

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

我想在这里使用 pathFor handlebars helper 和 _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}}

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

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

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

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