I am trying to work with the router and lazy loading in angular 8. I have previously successfully used it in Angular 7.
I have a few basic routes which are as follows:
/home
/auth
/auth/login
/auth/signUp
I would like /auth to redirect to /auth/login and everything else to redirect to /home.
To accomplish this, my app-routing.module.ts looks like this:
const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{
path: 'auth',
loadChildren: () => import('./modules/auth/auth.module').then(m => m.AuthModule)
},
{
path: 'home',
loadChildren: () => import('./modules/home/home.module').then(m => m.HomeModule)
},
{
path: '**',
redirectTo: '/home',
pathMatch: 'full'
}
];
And my auth-routing.module.ts looks like this:
const routes: Routes = [
{
path: '',
redirectTo: '/auth/login',
pathMatch: 'full'
},
{
path: 'login',
component: LoginComponent
},
{
path: 'signUp',
component: LogoutComponent
}
];
The problem is that it always redirects to the auth page and ignores the other redirects. The /login and /signUp paths are also available at a root level, which is odd, but they also work when prefixed with /auth/login which is even more peculiar.
So for some reason the routes seem to exist twice.
Also when I prefix the paths in auth-routing.module.ts with auth/ it is suddenly possible to direct to /auth/auth/login
I have activated all necessary features of Angular 8 to make ivy and lazy loading work. The other routes and lazy modules I have defined are working.