Feature to bind Router information to component inputs#49633
Feature to bind Router information to component inputs#49633atscott wants to merge 5 commits intoangular:mainfrom
Router information to component inputs#49633Conversation
ebce83c to
a957098
Compare
|
If you do "find usages" in your IDE you will see nothing and think it can be removed, right ? This would reduce the confidence while doing code cleanups. I wouldn't go this hidden magical path. Spring Boot uses |
This would still result in the same behavior with typescript not finding references. You can just as easily add a comment or |
People will miss doing both. Angular, as a framework, should advocate clarity. Because I think clarity brings confidence |
This makes sense! Thanks. |
a957098 to
a70713a
Compare
20ddb72 to
31768e4
Compare
jessicajaniuk
left a comment
There was a problem hiding this comment.
LGTM
reviewed-for: fw-core, public-api
…puts Adds ability for `RouterOutlet` to bind `Router` information to the routed component's inputs. This commit also exposes some helpers for implementers of custom outlets to do their own input binding if desired. Resolves angular#18967
…of ActivatedRoute The easiest way to access route data is now to use direct bindings to component inputs rather than going through `ActivatedRoute`. The tour of heroes guide still uses `ActivatedRoute` for now. I was hesitant to remove all of the content in one swoop and the tour of heroes is quite a bit more involved.
…nstead of ActivatedRoute
4e85185 to
9a018a4
Compare
|
Deployed aio for 9a018a4 to: https://ng-dev-previews-fw--pr-angular-angular-49633-dtzgtrva.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
|
(same existing failures on TAP as other PRs) |
|
This PR was merged into the repository by commit 81c9dd7. |
…of ActivatedRoute (#49633) The easiest way to access route data is now to use direct bindings to component inputs rather than going through `ActivatedRoute`. The tour of heroes guide still uses `ActivatedRoute` for now. I was hesitant to remove all of the content in one swoop and the tour of heroes is quite a bit more involved. PR Close #49633
Previously, 'Input' represented the value passed from the parent component. If the data comes from a Route, decorators such as "RouteParamInput", "RouteQueryInput", and "RouteStaticInput" should be provided to facilitate and strictly distinguish and control the source of the data. When a sub component needs to pass data from the parent component and also requires query input, it can confuse the developer because they do not know whether the data comes from the parent component or the route. I know I can set an alias, but it will increase user confusion and increase usage costs. I think adding new decorators is a better choice. If the user manually enters a query param on the route, it will cause the value of the Input to be overwritten. At this point, this value is not secure. like:
@Input() id: Observable<number>
@Input() id: // this value is ???
@RouteQueryInput() id?: string
@RouteParamInput() type?: string
@RouteStaticInput() someRouteStaticValue?: unkonw |
|
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. |
Adds ability for
RouterOutletto bindRouterinformation to the routedcomponent's inputs. This commit also exposes some helpers for
implementers of custom outlets to do their own input binding if desired.
Resolves #18967
Edit to add some more color to the "required inputs" / no references / no compiler warning for the inputs:
dataorresolveitems can be known at compilation time.dataorresolveof theRoutedefinitions. However, this would require developers to set the runGuardsAndResolvers option at least to'pathParamsOrQueryParamsChange'. This was undesirable from a usability and discoverability standpoint.RouterOutlet, required inputs cannot be checked by the compiler. This is also true of any other component created dynamically.Routeto define what bindings to set on the component. Similar to the point above, this was much more verbose than desired.