如何使用Meteor和Iron Router检查模板中路由名称的路由 [英] How to check for Route through route name in template with Meteor and Iron Router

查看:99
本文介绍了如何使用Meteor和Iron Router检查模板中路由名称的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在模板中使用什么来找出与我当前所在路线相关联的路线名

What can I use in a template to figure out the route name that is associated with the route that I am currently on?

例如,如果我在铁路由器中配置了这样的路线

this.route('quick', {
    path: '/wow/:_id',
    template: 'create_question'
});

所以,如果我在路线 / wow / 123 如何在我的模板中获取路由器的名称,在这种情况下如何在模板中获得 quick

So if I am on the route /wow/123 how can I get the router's name in my template, in this case how can I get quick in my template?

我只是在寻找一个功能,我相信我可以使用一个把手助手来完成剩下的工作。我只需要一个函数来调用。

I'm simply looking for a function, I am sure I can use a handlebars helper to get the rest done. I just need a function to call.

推荐答案

iron-router> 1.0



iron-router > 1.0

var routeName = Router.current().route.getName();



iron-router< 1.0



iron-router < 1.0

var routeName = Router.current().route.name;

这篇关于如何使用Meteor和Iron Router检查模板中路由名称的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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