The rediretTo property in the Router now accepts a function since version 18. That can return a string or UrlTree.
I have found one nice use case for it.
Imagine you have following routes
{
path: 'users',
children: [
{ path: '', redirectTo: 'list', pathMatch: 'full' },
{ path: 'list', component: UserList },
{ path: 'settings', component: UserSettings },
]
}
Here when we visit the /users we are redirected to /users/list.
Now you are asked to create one more entry in the users page, that is Overview Page.
Now this page should be under a feature flag or we protect it for some users. The update routes would look like this
