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
The problem is, that I can't really access route name from instruction, so I can't really create links for the crumbs, workaround was to duplicate name in data(https://gitter.im/angular/angular?at=564a3e5daca9bb7c6e508203) which is not ideal, but there seems to be no other way at the moment.
another problem, I need some sort of "proxy", so when I have component tree that looks like this
Users
UsersList
UsersDetail
Where Users is not terminal, I'd be able to show breadcrumb that looks like this UsersList -> UsersDetail.
As in uiBreadcrumbs I wanted to do that by defining some sort of breadcrumbsProxy: <something> on data of Users route. Which would require searching thru all routes and get one that matches <something>. Since there's no way to access the whole route tree, the only possible way I came up with was using router.recognize(url), so my breadcrumbsProxy looks like this breadcrumbsProxy: '/users/list'... BUT!
Apparently router.recognize('/users/list') does not return instruction for UsersList, but rather for Users with UsersList as a child.. which is kinda useless.
So, what would make it easier would be a way to search for a router by something.. say linkParams perhaps? So I'd do
router.getInstructionByLinkParams(['Users','UsersList'])// returns instruction for UsersList route
changed the title [-]angular2/router breadcrumb component.. expose route name/as to instruction?[/-][+]angular2/router breadcrumb component[/+]on Nov 17, 2015
Another thing is how hard is it to actually get linkParams from instruction, so I can recreate the link in breadcrumb, what I'm currently doing is concatenating the instruction tree and manually composing the linkParams array like this https://gist.github.com/fxck/108dccf4529becf9bc92#file-breadcrumb-ts-L76 it's gonna be even worse when I manage to get that proxy working, since I'll have to keep two arrays of instructions, one "real", for generating UsersDetail linkParams, one "fake", for proxied UsersList.
It would be really great if I could just pass instruction to router and get back linkParams.. so something like
Looks like this is actually implemented, only the docs are wrong.
router.generate(['something', 'child']) does generate instruction instead of url, contrary to the docs which reads Generate a URL from a component name and optional map of parameters. The URL is relative to the app's base href.
Unfortunately .generate(['/Users/UsersList']) does the same thing as .recognize('/users/list').. which is to return parent instruction (Users) with the instruction I'd expect, as a child... sucks
@tofful
The function transforms an instruction object into an array you can pass to the router.navigate function.
It just go into the nested object adding the component name and params to an array until it finds the terminal component or the instruction has no child component.
If you want to create breadcrumbs from that you could just map the array to get the user-friendly route names.
I just copied some instruction object from my app, you can see how it transform it to an array. JS Bin
I tried implementing breadcrumb component in my application and I was successful in it.
The only thing I want to know that, how to add child routes of a particular module.
Home User Manage User Add User Update user
The above is my routing structure.
User is a module under which there are several children components.
Now, what I want is, my breadcrumb to come like the below.
Home > ManageUser > Adduser (when I am navigating to Adduser from manageuser on a button click)
or, if I am updating
Home > ManageUser > Updtateuser(when I am navigating to UpdateUse from manageuser on a button click)
Activity
fxck commentedon Nov 17, 2015
another problem, I need some sort of "proxy", so when I have component tree that looks like this
Where
Usersis not terminal, I'd be able to show breadcrumb that looks like thisUsersList -> UsersDetail.As in uiBreadcrumbs I wanted to do that by defining some sort of
breadcrumbsProxy: <something>ondataof Users route. Which would require searching thru all routes and get one that matches<something>. Since there's no way to access the whole route tree, the only possible way I came up with was usingrouter.recognize(url), so my breadcrumbsProxy looks like thisbreadcrumbsProxy: '/users/list'... BUT!Apparently
router.recognize('/users/list')does not return instruction forUsersList, but rather forUserswithUsersListas a child.. which is kinda useless.So, what would make it easier would be a way to search for a router by something.. say
linkParamsperhaps? So I'd do?
[-]angular2/router breadcrumb component.. expose route name/as to instruction?[/-][+]angular2/router breadcrumb component[/+]fxck commentedon Nov 17, 2015
Another thing is how hard is it to actually get
linkParamsfrom instruction, so I can recreate the link in breadcrumb, what I'm currently doing is concatenating the instruction tree and manually composing thelinkParamsarray like this https://gist.github.com/fxck/108dccf4529becf9bc92#file-breadcrumb-ts-L76 it's gonna be even worse when I manage to get that proxy working, since I'll have to keep two arrays of instructions, one "real", for generating UsersDetaillinkParams, one "fake", for proxied UsersList.It would be really great if I could just pass instruction to router and get back
linkParams.. so something likebtford commentedon Nov 17, 2015
Yep, this is something we want to do, but haven't gotten to yet. 👍
fxck commentedon Nov 18, 2015
Looks like this is actually implemented, only the docs are wrong.
router.generate(['something', 'child'])does generate instruction instead of url, contrary to the docs which readsGenerate a URL from a component name and optional map of parameters. The URL is relative to the app's base href.fxck commentedon Nov 18, 2015
Unfortunately
.generate(['/Users/UsersList'])does the same thing as.recognize('/users/list').. which is to return parent instruction (Users) with the instruction I'd expect, as a child... sucksPavelPZ commentedon Mar 13, 2016
@btford great, thank you, I am waiting for it. "Accessing route name from instruction" is very important feature (not only for breadcrumb component).
afirdousi commentedon Mar 19, 2016
Any updates on this guys ?
sviat-barbutsa commentedon Apr 6, 2016
any? :)
fxck commentedon Apr 6, 2016
yea use https://github.com/ngrx/store should be a breeze to make breadcrumb comp there
leovrf commentedon Apr 14, 2016
+1
sebasgavi commentedon May 7, 2016
@fxck I'm using this recursive function to generate the array from the instrucion, works fine for me
I'm using underscore to check if params is empty but it should work just fine with a custom check
tofful commentedon May 27, 2016
@vagyriag could you give us more info or a plunkr of your solution :) I am addressing the same problem creating breadcrumb. thanks a lot
sebasgavi commentedon May 27, 2016
@tofful
The function transforms an instruction object into an array you can pass to the
router.navigatefunction.It just go into the nested object adding the component name and params to an array until it finds the
terminalcomponent or the instruction has no child component.If you want to create breadcrumbs from that you could just map the array to get the user-friendly route names.
I just copied some instruction object from my app, you can see how it transform it to an array. JS Bin
vsavkin commentedon Jul 7, 2016
We are no longer maintaining the deprecated router to focus our efforts on making the new router robust.
It doesn't look like the issue makes sense in the context of the new router. If you think it does, please reopen the issue.
mrajcok commentedon Aug 7, 2016
For a solution that uses the new router, see http://stackoverflow.com/questions/38312417/angular2-router-get-route-data-from-url-to-display-breadcrumbs
Sunanda94 commentedon Mar 14, 2019
Hi
I tried implementing breadcrumb component in my application and I was successful in it.
The only thing I want to know that, how to add child routes of a particular module.
Home
User
Manage User
Add User
Update user
The above is my routing structure.
User is a module under which there are several children components.
Now, what I want is, my breadcrumb to come like the below.
Home > ManageUser > Adduser (when I am navigating to Adduser from manageuser on a button click)
or, if I am updating
Home > ManageUser > Updtateuser(when I am navigating to UpdateUse from manageuser on a button click)
Please go through my application and provide me some solutions
https://github.com/Sunanda94/Breadcrumb
angular-automatic-lock-bot commentedon Sep 14, 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.