In my app.module.ts
file , I import (eagerly) LoginModule
which has its own routing module (login-routing.module.ts
- let's say I can't change it)
I also import another routing module (AppRoutingModule
- which deals with all lazy modules) .
app.module.ts:
@NgModule({
bootstrap : [AppComponent],
imports : [
...
LoginModule,
AppRoutingModule
...
]...
The login-routing.module.ts
file has its own routing :
login-routing.module.ts :
const LoginRoutes: Routes = [
{
path : 'welcome',
component: WelcomeComponent
},
{
path : 'loginSms',
component: LoginSmsComponent
},
{
path : 'loginPassword',
component: LoginPasswordComponent
},
{
path : 'passwordExpired',
component: PasswordExpiredComponent
}
];
@NgModule({
...
})
export class LoginRoutingModule
{
}
And AppRoutingModule
has :
const routes: Routes = [
/* { path : "", redirectTo: "/welcome", pathMatch : "full"},*/
{
path : 'app',
children: [
{
path : "home",
loadChildren: "~/modules/home/home.module#HomeModule"
},
{
path : "payments",
loadChildren: "~/modules/payments/payments.module#PaymentsModule"
}
]
}
...
Please notice that I've used ComponentLess route with prefix app
just to organize routes.
So where is the problem?
I want to add the Login routes to "app routes" , so that I will access login routes as :
app/login/...
In other words - now - AppRoutingModule
should be :
path : 'app',
children: [
{
path : "home",
loadChildren: "~/modules/home/home.module#HomeModule"
},
{
path : "payments",
loadChildren: "~/modules/payments/payments.module#PaymentsModule"
},
{
path : "login",
//but how o I load all `login-routing.module.ts` routes here ?
},
]
But LoginModule
should be eager loaded and not lazy loaded , so I can't use loadChildern
.
Question:
In short , how can I access the login module routes as :
app/login/loginPassword
instead of
/loginPassword
?