-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In some usecases, changing parent route url parameter should not reset child route #7378
Comments
@cporte you can the |
Hum, maybe I failed when I tested this solution, but it didn't work. Or is there a special mecanism keeping the child routes when the |
@cporte It works if you're visiting the same route component multiple times, so going from |
Hum, I don't know how to explain better the use case. I would like to go from Basically, I was able to do a similar thing by using queryString instead of route parameters (so having URL like |
Ok, I see. Its a matter of how your routes are setup. @RouteConfig([
{ path: '/', ... }, // home
{ path: '/help', ... }, // help
{ path: '/projects', ...}, //the page to CRUD the projects
{ path: '/projects/:idProject/results/per-categories/top5chart', ...} //an hidden page far far away but still useful
])
class App {} If your routes are setup like this, then your routes under your project path won't be grouped. If you want to group all project related paths, you would do: @RouteConfig([
{ path: '/', ... }, // home
{ path: '/help', ... }, // help
{ path: '/projects/:idProject/...', component: Projects, name: 'ProjectExploration' } //the page to CRUD the projects
])
@Component({...}) // include a <router-outlet></router-outlet>
class App {}
@RouteConfig([
{ path: '/results/per-categories/top5chart', name: 'TopResults', useAsDefault: true } //an hidden page far far away but still useful
])
@Component({...}) // include a <router-outlet></router-outlet>
class Projects {} This allows you to build your child so they all include the project ID. <a [routerLink]="['ProjectExploration', {idProject: 462}, 'TopResults']">Project 462 Top Results</a>
<a [routerLink]="['ProjectExploration', {idProject: 463}, 'TopResults']">Project 463 Top Results</a> |
Yes, this would be my setup for the components. My issue is more that the project selector is at the parent level and is not supposed to be aware of children routes (). But as soon as a route has a parameter, It's kind of tricky to decide that if the parameter change, the route is considered totally different and we have to reset both the children parts and the query parameters. |
Ok. You could look into the |
Thanks, but I think I still didn't made my request clear. Basically a changed a bit URLs and component to be clearer. I hope this time my explanations are less confused :) |
Code always helps 😄 ... The way the router does deep linking goes against what you're trying to do here. To deep link you have to provide the entire route path from parent to child. Based on what you've described, it sounds like you need dynamic router links on your RoutingPage. You would need to use something to store the route array with the current project, month, year, etc and update that route array when you visit one of the child routes, and your router links in your RoutingPage reference that array with the correct project. That way you're RoutingPage doesn't have to have explicit knowledge of the children, but they are provided with the route array that creates the deep link. I can try to put a plunker together if this isn't clear enough. |
Thanks for your reply. The question now is "should the router cover this kind of requirements?". I would tend to keep this enhancement request, maybe cleaning it for better understanding, and see how the other users see this use case. For what I saw in some other github issues the new router have other limitations (coupling between components and routes, lack of input/output support between parent and children, difficulties to access all the parameters of all routes, etc) and if at some point there is a redesign of the router in the future I would love to see my request discussed along with the others. If you have some time, a plunker would be nice, but I see the concept. The only point I don't see now is how can I track the current routes in a service (or in the root component). Last time I tried to inject some routing stuff (like Location, or things like that) and listening to them I wasn't able to track the URL changes |
One additional consideration, as I'm studying Angular 2 more in details to find workaround. |
obsolete |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In some applications, we may want to have a multiple step edition of a complex object, with multiple sub-screens
Imagine the following routes:
/ //the home page
/help //an help page
/projects //the page to CRUD the projects
/projects/:idProject/results/per-categories/top5chart //an hidden page far far away but still useful
The user may want to change the currently selected projet (in a side menu for exemple) without loosing the current route.
Currently, the only way to achieve this behaviour easily (i.e. with router-link) is to use queryParams for the idProject
It would be great if there were a way to configure the routing to permits this behaviour without using queryParams (and ugly URLs)
The text was updated successfully, but these errors were encountered: