Skip to content
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

Component Input Binding - can child of the parent access the params of the parent, via component input binding syntax? #55863

Closed
dreamstar-enterprises opened this issue May 17, 2024 · 4 comments

Comments

@dreamstar-enterprises
Copy link

dreamstar-enterprises commented May 17, 2024

Which @angular/* package(s) are relevant/related to the feature request?

core, router

Description

Can child components of the parent that has the param also access the e.g. params :id
Right now, I have to pass all the inputs from the parent (which is the container), into the child's via the component [input] parameter.
Would be great if the childs could also access the input bindings of the parent.
Not sure how the Angular team views this, maybe something they have already thought about?

Proposed solution

Propose input bindings to be directly accessible by child components (not those loaded via router outlet, but actual components put into the view template of the parent)

Alternatives considered

Currently having to manually pass through the parent down to the child.
The parent (in my case a container), has no real interest in the params, it is the child that does.

@dreamstar-enterprises dreamstar-enterprises changed the title Component Input Binding - can child of the parent that has the param also access the e.g. params Component Input Binding - can child of the parent access the params of the parent, via component input binding syntax? May 17, 2024
@JeanMeche
Copy link
Member

JeanMeche commented May 17, 2024

Yes this is accessible with the { paramsInheritanceStrategy: 'always' } option.

See : https://angular.dev/api/router/RouterConfigOptions and https://timdeschryver.dev/blog/til-paramsinheritancestrategy-to-always-have-access-to-parent-route-info

@JeanMeche JeanMeche closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@dreamstar-enterprises
Copy link
Author

dreamstar-enterprises commented May 17, 2024

Hi, thanks.

I just tried this, and it doesn't work when the child is just a component of the parent's view template
e.g.

<parent>

<router outlet></router outlet> - works I suppose with the paramsInheritanceStrategy

<child></parent> - doesn't seem to be accessible here

</parent>

@JeanMeche
Copy link
Member

Route Input binding is only accessible for routed components.
You're observing the designed behaviour.

@dreamstar-enterprises
Copy link
Author

Thanks for clarifying !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants