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 navigation with lazy loading modules. #17957
So, when i'm on the Child1 a wanna navigate to child 2 with this.router.navigate(['../child2'], {relativeTo: this.activatedRoute})
And we get parent/child1/child2
But in cause of empty section added with lazy loading module configuration i should use this.router.navigate(['../../child2'], {relativeTo: this.activatedRoute})
Because in fact we have parent/child1 + ''
Expected behavior
We get parent/child2
Is there any way to change this behaviour ?
Becouse with many nested lazy loading modules we'll get a littlebit
empty sections and we'll write ../../../../../../sibling to go sibling route.
Minimal reproduction of the problem with instructions
any application with lazy loading modules. Just try navigate to sibling route. plunker
go down to member and try go back with two buttons.
Only ./../../../ is working.
What is the motivation / use case for changing the behavior?
Please tell us about your environment
Angular version: 4.1.3
Browser: any
Reacted by Ruslan Butyk, AntonHavryliaka, Serhii, RevProg, merovinh, diemord, otsmyg, Yuriy Yakovenko, Brady Shutt, Masahiro Nishida and 47 more
@AndriiDidkivsky Do you happen to know if this is directly related to lazy loading or not? In other words, would this work if you weren't using lazy loading, but still using a children array?
Basically wondering if this relates to lazy loading or routing in general.
@jasonaden , it's completely lazy-loading issue.Here is the same plunker but without lazy loading and it works correctly. We go parent route with ./../ unlike of previous version.
It seems that the router.navigate doesn't work for lazy module. (we are using ng.version: 4.1.3)
Below just a temporary solution using a tag with routerLink prop.
This bug hits me again and again and again. Can't believe that it's not going to be fixed.
Why is something as fundamental as relative navigation left broken?
I'm a newbie at Angular and have been trying to figure this problem myself out for a weekend. I think I finally have 'an' answer. Since you're lazy loading the modules, any where you use this.router.navigate(this.returnUrl), for example, you must add the name of the child module at the beginning. For me it was this.router.navigate(['/admin + this.returnUrl]);
I thought for sure I was doing something wrong for such a fundamental functionality to be broken, and I spent a couple days banging my head into this problem. Amazing that this could be open for a year and a half. Makes me question my use of Angular.
I'm in 7.1.4 and facing the same problem. I think the whole router thing goes against "convention over configuration" and its too messy and complicated, NOTHING works as expected, and the information supplied in documentation is not sufficient. This is very discoraging, im tired and wasting time trying to figure out how this damm thing works. I'm going to try another framework, Screw this!
Reacted by Miguel Vazquez, Bharathi Ram and Charlie Greenman
Reacted by Maciej Sawicki, Giovanni Filippi, Michele Schäuble, Jakub Pistek, Raj Sekhar, Indiana Zhao, Lennie, denu5, Andreas Bjerga and Yuriy Yakovenko
Reacted by Raj Sekhar, Charlie Greenman , denu5 and Brad
Activity
AndriiDidkivsky commentedon Jul 7, 2017
In my app activatedRoute.pathFromRoot looks pretty strange.
Each activatedRoute has component property and if extract it array looks like
So, before every lazy-module we have undefined component.
AndriiDidkivsky commentedon Jul 12, 2017
Guys, i've added plunker. Hope it'll help.
djleonskennedy commentedon Jul 12, 2017
Hello all, totally critical issue, is there any plans to fix it, or suggest workaround
Thank you
ruslan-butyk commentedon Jul 12, 2017
+1
Did someone response?
Fix this issue will be very helpful for me.
otsmyg commentedon Jul 13, 2017
Anybody fixed this?
jasonaden commentedon Jul 18, 2017
Thanks for the issue. We will discuss this one in the next couple days and update here.
AndriiDidkivsky commentedon Jul 18, 2017
Thx, guys.
jasonaden commentedon Jul 18, 2017
@AndriiDidkivsky Do you happen to know if this is directly related to lazy loading or not? In other words, would this work if you weren't using lazy loading, but still using a
childrenarray?Basically wondering if this relates to lazy loading or routing in general.
AndriiDidkivsky commentedon Jul 19, 2017
@jasonaden , this relates just for lazy loading. I'll check again today and let you know.
I can create another plunker, without lazy loading if needed
AndriiDidkivsky commentedon Jul 19, 2017
@jasonaden , it's completely lazy-loading issue. Here is the same plunker but without lazy loading and it works correctly. We go parent route with ./../ unlike of previous version.
AndriiDidkivsky commentedon Jul 26, 2017
Guys, any updates of this issue? We,re writing the big app and this thing is very important for us.
Tnx.
issasami commentedon Aug 9, 2017
Any updates about issue?
undermoodzyx commentedon Aug 23, 2017
I met the same question.
It seems that the
router.navigatedoesn't work for lazy module. (we are usingng.version: 4.1.3)Below just a temporary solution using
atag withrouterLinkprop.issasami commentedon Aug 23, 2017
27 remaining items
uvconnects commentedon Aug 2, 2018
adorep commentedon Aug 10, 2018
This bug hits me again and again and again. Can't believe that it's not going to be fixed.
Why is something as fundamental as relative navigation left broken?
uvconnects commentedon Aug 10, 2018
bertvan commentedon Sep 18, 2018
+1
flyingsolo62 commentedon Oct 1, 2018
I'm a newbie at Angular and have been trying to figure this problem myself out for a weekend. I think I finally have 'an' answer. Since you're lazy loading the modules, any where you use this.router.navigate(this.returnUrl), for example, you must add the name of the child module at the beginning. For me it was this.router.navigate(['/admin + this.returnUrl]);
cknolla commentedon Jan 21, 2019
I thought for sure I was doing something wrong for such a fundamental functionality to be broken, and I spent a couple days banging my head into this problem. Amazing that this could be open for a year and a half. Makes me question my use of Angular.
antwalls commentedon Jan 27, 2019
I'm in 7.1.4 and facing the same problem. I think the whole router thing goes against "convention over configuration" and its too messy and complicated, NOTHING works as expected, and the information supplied in documentation is not sufficient. This is very discoraging, im tired and wasting time trying to figure out how this damm thing works. I'm going to try another framework, Screw this!
jbonfante commentedon Jan 27, 2019
There appears to be a fix in this PR #26990
but you may have to modify the router config for it to take effect. Have not tried this yet in 7.
Humberd commentedon May 7, 2019
Any updates?
hansmaad commentedon May 9, 2019
I had to add the
relativeLinkResolutionoption to the app routing config. It's strange that the buggy behaviour is selected by default.https://angular.io/api/router/ExtraOptions#relativeLinkResolution
Humberd commentedon May 9, 2019
@hansmaad Thank you. Your solution works like a charm.
vladimiry commentedon May 9, 2019
Good finding. It was fixed more than a year ago #22394 but appeared here only now.
angular-automatic-lock-bot commentedon Oct 27, 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.