Reputation: 75
I expect www.mypage.com/users
to be routed to www.mypage.com/users/1
, how can this be achieved?
I tried following
path: 'users', redirectTo: '1', pathMatch: 'full', children: [
{ path: ':id', component: UsersComponent }
]
I could also return 404 page but thats not what I want.
Upvotes: 1
Views: 103
Reputation: 136184
This can be done by using adding one more child route with ''
(blank) path check inside child route. But you have to create an parent component which template would have router-outlet
once again.
{
path: 'users', component: UserWrapperComponent,
children: [
{ path: '', redirectTo: '1', pathMatch: 'full' }
{ path: ':id', component: UsersComponent }
]
}
Upvotes: 2
Reputation: 1517
Try this,
{path: 'users', redirectTo: 'users/1', pathMatch: 'full', children: [
{ path: '1', component: UsersComponent }
]
Upvotes: 0