Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

javascript - How to check for Route through route name in template with Meteor and 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?

For example if I configured a route like so in iron-router

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

iron-router > 1.0

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

iron-router < 1.0

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...