-
Notifications
You must be signed in to change notification settings - Fork 27k
Description
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
When routing to a component, one must inject the ActivatedRoute service to retrieve route data for use inside the component.
Expected behavior
When defining routes, specific params could be used to provide values for @inputs within the component. For example:
const routes:Routes = [
{path: '', redirectTo: 'home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'search:searchTerm', component: SearchComponent, inputs: { searchTerm: searchTerm }}, // bind the @Input searchTerm from SearchComponent to the searchTerm route parameter
{path: '**', component: HomeComponent}
];
Minimal reproduction of the problem with instructions
Configure the above routes; specifying data to be passed to component @inputs is not possible.
What is the motivation / use case for changing the behavior?
My team and I are creating completely modular components and publishing them on our private npm repo so that they may be used in any Angular application. We are achieving this modularity through the use of @inputs, however now we are finding that these are not adequate if wanting to provide data through route/URL parameters.
What we are finding is that now we will have to use either @inputs or route/URL parameters to provide dynamic data, or use them both in combination but this presents the problem of having to decide which takes precedence if both are present.
This in my opinion breaks the modularity and reusability provided by the @input functionality that is inherent to components.
Environment
Angular version: 4.3.5
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others: