Is there a way to manage redirect routes when users enter the wrong URL using wildcards controlled by conditions?
In my project, I have 3 main modules that are separate, and each of them has specific conditions for user access based on roles.
The issue I am facing is that I am unsure how to handle this based on conditions. I have attempted to use canActivate but it does not seem to be working.
Main.ts:14 Error: Invalid configuration of route '**'. One of the following must be provided: component, redirectTo, children, or loadChildren
Here is some of my code:
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'customer1'
},
{
path: 'customer1',
component: RootOneComponent,
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'home'
},
{
path: 'home',
component: HomeOneComponent
},
{
path: '**',
component: PageNotFoundComponent
}
],
},
{
path: 'customer2',
component: RootTwoComponent,
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'home'
},
{
path: 'home',
component: HomeTwoComponent
},
{
path: 'BlogPicture',
loadChildren: () => import('./blog/blog.module').then(m => m.BlogModule)
},
{
path: '**',
component: PageNotFoundComponent
}
],
},
{
path: 'customer3',
component: RootThreeComponent,
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'home'
},
{
path: 'home',
component: HomeThreeComponent
},
{
path: 'blog-price',
loadChildren: () => import('./blog/blog.module').then(m => m.BlogModule)
},
{
path: '**',
component: PageNotFoundComponent
}
],
},
// Is there a way to manage wildcard conditions here?
{
path: '**',
redirectTo: 'classic'
}
];