Skip to content Skip to sidebar Skip to footer

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.

Solution 1:

iron-router > 1.0

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

iron-router < 1.0

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

Solution 2:

For the newer iron router, use:

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

This will output the name of the actual route you defined with this.route()

Solution 3:

You can define any options you want in your route config :

Router.route('/', {
    name : 'home',
    template : 'home',
    title: 'Home'
});

and then access to title with this :

Router.current().route.options.title

This will output "Home"

Solution 4:

You can try Router.current().template

Post a Comment for "How To Check For Route Through Route Name In Template With Meteor And Iron Router"