You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Router question/FR] How to expose route name? #5180
This is just for a name property, but exposing all the info it would be nice too and you could name it RouteInfo or so and make it injectable and I totally came up with that name, I didn't steal it from anyone. Notethat this one would be not the same as RouteData
Something like this
constructor(routeInfo: RouteInfo) {
// Get the name for this particular route
routeInfo.getName()
}
My workaround so far is this little piece of code
constructor(router: Router) {
router.registry._rules.forEach((val) => {
val.names.forEach((v, k) => console.log(v, k));
// 'k' is the route name and 'v' is a lot of weird things
});
Not good, I'm iterating over something private, but it's one solution so far.
A shorter one would be this
{path: '/index', component: RoutingIndex, name : 'Index', data : {'name':'Index'}}
But that seems a little redundant and I would have to repeat it in every route and yes, I'm super lazy.
Any advice? Am I missing something obvious? Please don't say use the data property
@behzadeshan that seems like another good idea, but I'm not trying to retrieve the name from the URL. The user can write anything on it so it's not so safe. Besides that, it's not only about getting the path name but also getting the Route info, that's what I think getting the name from the Route would be safer. I'll keep in mind your suggestion, thanks 👍
For now I'll stick to data property since the user can't modify it.
Activity
ericmartinezr commentedon Nov 8, 2015
@behzadeshan that seems like another good idea, but I'm not trying to retrieve the name from the URL. The user can write anything on it so it's not so safe. Besides that, it's not only about getting the path name but also getting the Route info, that's what I think getting the
namefrom the Route would be safer. I'll keep in mind your suggestion, thanks 👍For now I'll stick to
dataproperty since the user can't modify it.angular-automatic-lock-bot commentedon Sep 7, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.