Reputation: 1
I can not implement multi-level routing with params in Angular js 2 using router.navigate.
These are my code, just a child route.ts and a component use the navigate, note that I already can use the path '' and 'manageDealers' which mean this route.ts was valid
route.ts
export const dealerRoutes : Routes = [
{
path: 'dealers',
children: [
{
path: '',
redirectTo: 'manageDealers'
},{
path: 'manageDealers',
component: DealerManage,
},{
path: ':dealerId/users/:userId',
name: 'DealerUserDetailManage',
component: DealerUserDetailManage,
}
]
}
]
component.ts
viewDetail(dealerId:number,userId:number){
this.router.navigate([''DealerUserDetailManage',{dealerId: dealerId, userId: userId}]);
}
Did not work
Upvotes: 0
Views: 248
Reputation: 238
Edit the route.ts the default route redirectTo
needs /
too. try the code like this:
export const dealerRoutes : Routes = [
{
path: 'dealers',
children: [
{
path: '',
redirectTo: '/manageDealers',
pathMatch:'full'
},{
path: 'manageDealers',
component: DealerManage,
},{
path: ':dealerId/users/:userId',
name: 'DealerUserDetailManage',
component: DealerUserDetailManage,
}
]
}
]
Upvotes: 1