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

ActivatedRoute params should include parent parameters, from root #20572

Closed
voithos opened this Issue Nov 21, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@voithos
Contributor

voithos commented Nov 21, 2017

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Currently, the router has some special casing for when parent route parameters are inherited by child ActivatedRoutes. Specifically, they are only inherited if the parent route was either (1) configured without a component, or (2) configured with path: ''.

Expected behavior

It seems like it'd be more useful to allow the option of just unconditionally flattening params from the root to the current route. This would allow child pages to have easy access to params defined in parent routes.

What is the motivation / use case for changing the behavior?

Child routes often need to access parameters defined on parent routes, and this would make it much simpler to reliably have the params available in the ActivatedRoute that is injected into the child component (and avoid the unpredictability of the current merging approach).

Environment

Angular version: HEAD
@trotyl

This comment has been minimized.

Show comment
Hide comment
@trotyl

trotyl Nov 23, 2017

Contributor

Duplicate of #11023

Contributor

trotyl commented Nov 23, 2017

Duplicate of #11023

@voithos

This comment has been minimized.

Show comment
Hide comment
@voithos

voithos Nov 23, 2017

Contributor

If I'm reading it correctly, I think #11023 is a bit different. That discussion mentions sibling components and even components that are outside a <router-outlet>. The parameters described in this issue are all reachable (you just have to navigate up the ActivatedRoute.parent chain), but the feature request is about making them present in the child ActivatedRoute such that explicitly referencing ActivatedRoute.parent is unnecessary.

Contributor

voithos commented Nov 23, 2017

If I'm reading it correctly, I think #11023 is a bit different. That discussion mentions sibling components and even components that are outside a <router-outlet>. The parameters described in this issue are all reachable (you just have to navigate up the ActivatedRoute.parent chain), but the feature request is about making them present in the child ActivatedRoute such that explicitly referencing ActivatedRoute.parent is unnecessary.

voithos added a commit to voithos/angular that referenced this issue Nov 29, 2017

feat(router): add "alwaysInheritParams" router configuration option
Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"alwaysInheritParams" which makes child routes unconditionally inherit
params from parent routes. This closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Nov 29, 2017

feat(router): add "alwaysInheritParams" router configuration option
Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"alwaysInheritParams" which makes child routes unconditionally inherit
params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Nov 29, 2017

feat(router): add "alwaysInheritParams" router configuration option
Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"alwaysInheritParams" which makes child routes unconditionally inherit
params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Dec 12, 2017

feat(router): add "inheritParams" router configuration option
Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"inheritParams" which, when set to 'always', makes child routes
unconditionally inherit params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Dec 14, 2017

feat(router): add "inheritanceStrategy" router configuration option
Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"inheritanceStrategy" which, when set to 'always', makes child routes
unconditionally inherit params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Dec 15, 2017

feat(router): add "paramsInheritanceStrategy" router configuration op…
…tion

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Dec 15, 2017

feat(router): add "paramsInheritanceStrategy" router configuration op…
…tion

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Dec 15, 2017

feat(router): add "paramsInheritanceStrategy" router configuration op…
…tion

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Dec 16, 2017

feat(router): add "paramsInheritanceStrategy" router configuration op…
…tion

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes angular#20572.

voithos added a commit to voithos/angular that referenced this issue Dec 18, 2017

feat(router): add "paramsInheritanceStrategy" router configuration op…
…tion

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes angular#20572.

alxhub added a commit that referenced this issue Dec 20, 2017

feat(router): add "paramsInheritanceStrategy" router configuration op…
…tion

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes #20572.

jmleoni pushed a commit to jmleoni/angular that referenced this issue Oct 6, 2018

feat(router): add "paramsInheritanceStrategy" router configuration op…
…tion

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes angular#20572.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment