Closed meeroslav closed 4 years ago
@brandonroberts please verify if you agree with this functionality
How does this handle naming collisions? I want to keep the route params relatively straightforward, and lean more on using the components to pass data around then trying to collect them all in the router service.
Currently, the child param has priority over the parent param:
// root params -> child params -> child params => pathRoutes
{ owner: 'Joe' } -> { car: 'Mustang' } -> { owner: 'Jane' } => { owner: 'Jane', car: 'Mustang' }
My rationale was to provide as many features as possible from the official @angular/router
to motivate devs to migrate. Two of those features missing are:
With the original router, we can access easily all path params (should a component need it). The current solution with angular-routing
is to depend on parent components to pass it down to the child component. This leads to a rigid structure and complications when the component is moved around through DOM.
Back to name handling, we could return Params[]
instead of Params
. That would avoid naming collision and perhaps also provide more sense of hierarchy of params.
What do you think?
We discussed tabling this feature for now, but will revisit
Problem:
Expose route params from the router component back to router service to have it available for all components.
The tricky part:
Since routes are not configured in central configuration (like in @angular/router) but rather loaded and parsed asynchronously from components, the
routeParams
will change until parsing has been fully finished.Unrelated bug fixed separately (found in router component and service):
distinctUntilChanged
does value referential comparison. It works nicely for strings, but for objects (such asParams
) a custom comparison function must be provided e.g.: