2016-11-21 62 views
0

我在我的routes.js文件中有多條路線,我想向其中引入一個額外的字段。下面是路由流星路線中的自定義字段

Router.route('/', { 
    name: 'home', 
    controller: 'LoginController', 
    where: 'client', 
    action:'index' 
}); 

,因爲我有許多途徑,我想通過所有路線,並得到路由名這樣

_.each(Router.routes, function(route){ 
    console.log(route.getName()); 
}); 

我想使用的路線名稱生成鏈接。鏈接需要鏈接名稱,我有將鏈接名稱放在路由中的想法。

Router.route('/', { 
    name: 'home', 
    controller: 'LoginController', 
    where: 'client', 
    text: 'Login Link', 
    action:'index' 
}); 

在流星允許的路線中引入自定義字段?

回答

0

我發現有一個title選項,但它不是在文檔http://iron-meteor.github.io/iron-router/#route-specific-options

,並用它這樣

Router.route('/', { 
    name: 'login', 
    controller:'HomeController', 
    where: 'client', 
    title: 'login', 
    icon: 'this is the icon', 
    action:'index' 
}); 

,並獲得選項

Router.routes.forEach(function(route){ 
    console.log(route.getName()); 
    console.log(route.options.title); 
    console.log(route.options.icon); 
}); 

,這是結果

login 
login 
this is the icon 

所以即使自定義選項icon似乎工作。