Component Input Binding - can child of the parent access the params of the parent, via component input binding syntax?
dreamstar-enterprises opened this issue · comments
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.
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
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>
Route Input binding is only accessible for routed components.
You're observing the designed behaviour.
Thanks for clarifying !