Is there a way to access the routerParams in the redirecTo-Statement?
I want to pass the orderId of the 'Order' route to the 'OrderDashboard' route but I can't figure out what to write instead of ???
If I replace ???
with 3
all works fine (in case the user only is intrested in order number 3 ;-) )
{path: '/:orderId', name: 'Order', redirectTo: ['OrderDashboard', {orderId:???}]}
{path: '/:orderId/dashboard', name: 'OrderDashboard'}
Late to party but anyway,
I couldn't find any reference for accesing the routeParams
at the time of router.config
,
But still you can achieve the same behaviour by using one of these techniques
1. Defining two routes using Same Component
(not exactly same as url will be different in address bar)
{path: '/:orderId', name: 'Order', component: OrderDashboard}
{path: '/:orderId/dashboard', name: 'OrderDashboard', component: OrderDashboard}
2. Using a disposable component as proxy
{path: '/:orderId', name: 'Order', component: OnlyToRedirect}
{path: '/:orderId/dashboard', name: 'OrderDashboard', component: OrderDashboard}
export class OnlyToRedirect{
constructor(routeParams: RouteParams, router: Router){
router.navigate(['OrderDashboard', {orderId: routeParams.params}])
}
}
Hope this works :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With