Reputation: 787
I am trying to do lazyloading for different modules and i am trying to match route prefix to load module. But it is not working, it works for exact url but not for prefix. i am using angular 6.1.
this code does't work
{
path: 'account',
component: AuthComponent,
children: [
{
path: '',
loadChildren: './modules/auth/auth.module#AuthModule'
}
{
path: '**',
loadChildren: './modules/auth/auth.module#AuthModule'
}
]
},
and this code works fine
{
path: 'account',
component: AuthComponent,
children: [
{
path: '',
loadChildren: './modules/auth/auth.module#AuthModule'
},
{
path: 'login',
loadChildren: './modules/auth/auth.module#AuthModule'
},
{
path: 'register',
loadChildren: './modules/auth/auth.module#AuthModule'
},
{
path: '**',
loadChildren: './modules/auth/auth.module#AuthModule'
}
]
},
Do i have to map each route for loading module?
These are the routes i have in my module i am trying to load.
const routes = [
{
path: '',
component: LoginComponent,
data: {
title: 'login'
}
},
{
path: 'login',
component: LoginComponent,
data: {
title: 'login'
}
},
{
path: 'register',
component: RegisterComponent,
data: {
title: 'register'
}
},
{
path: 'admin/login',
component: LoginComponent,
data: {
title: 'Admin login'
}
}
];
Thanks in advance.
Upvotes: 0
Views: 1002
Reputation: 541
Try like this :
{
path: 'account', loadChildren: './modules/auth/auth.module#AuthModule'
},
const routes = [
{
path: '', component: AuthComponent,
},
{
path: 'login',
component: LoginComponent,
data: {
title: 'login'
}
},
{
path: 'register',
component: RegisterComponent,
data: {
title: 'register'
}
},
{
path: 'admin/login',
component: LoginComponent,
data: {
title: 'Admin login'
}
}
];
Upvotes: 1