How to check for Route through route name in template with Meteor and Iron Router

╄→гoц情女王★ 提交于 2019-11-28 20:24:55

iron-router > 1.0

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

iron-router < 1.0

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

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()

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"

You can try Router.current().template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!