In my Angular application, I have set up the following route configuration:
{
path: ParentComponent.path,
component: ParentComponent,
canActivate: [AuthGuard],
children: [
{
path: '',
pathMatch: 'full',
redirectTo: getDefaultChildRoute()
},
{
path: ':mode/:year/:month/:day',
component: ChildComponent
}
]
}
The function getDefaultChildRoute() is responsible for generating a string in this format:
export function getDefaultChildRoute(): string {
const urlArray = ['a', '2019', '02'];
return urlArray.join('/');
}
The issue here is that the redirectTo property requires a string value, not a method call (even if the method returns a string). When I replace the method call with a static string, it functions correctly.
There is a known issue related to this on GitHub: https://github.com/angular/angular/issues/13373
Attempting to use an arrow function directly in the redirectTo property results in a Typescript error '()=>string is not assignable to type string'.
Any suggestions on how to approach this problem?