[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
URL parameters are not stored in the router state snapshot.
They should be.
This demo has a link 'Test parameter', which navigates to a route using a url parameter.
It also shows the current router state, which is created using a custom serializer.
It should display the url parameter, but only shows the url itself.
http://plnkr.co/edit/rgNb1U72etGOZmTQP8ey?p=preview
Latest ngrx.
Your example is incorrect. Query params are bound as an input to a routerLink. If you want route specific parameters, you have to traverse the route tree to get the params from the current ActivatedRoute.
Here is a working example: http://plnkr.co/edit/l0O9AE?p=preview
@brandonroberts Ahh thanks so much for clearing that up! I was indeed talking about route specific parameters and it really wasn't clear I'd need to traverse the tree for those. Might be nice to add your solution to the serializer doc!
Just copying Brandon solution for future reference:
export class CustomRouterStateSerializer implements RouterStateSerializer<RouterStateUrl> {
serialize(routerState: RouterStateSnapshot): RouterStateUrl {
const { url } = routerState;
const queryParams = routerState.root.queryParams;
let route = routerState.root;
while (route.firstChild) {
route = route.firstChild;
}
const params = route.params;
return { url, params, queryParams };
}
}
Most helpful comment
Just copying Brandon solution for future reference: