I try to achieve lazy module loading but I don't succeed yet.
I want when the user go to /admin - then the AdminModule will start,
and when the user go to /admin/user - then UserComponenet of AdminModule will start.
This is the folder structure of my app:

In my app I have AppModule:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
const routes: Routes = [
{path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) }
];
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
RouterModule.forRoot(routes)
],
bootstrap: [AppComponent]
})
export class AppModule { }
AppComponent html file:
--- App Componenet --- <br /><br />
<a routerLink="admin">admin</a><br />
<a routerLink="admin/home">admin/home</a><br />
<a routerLink="admin/user">admin/user</a><br />
<br /><br />
Router outlet result: <br />
<router-outlet></router-outlet>
AdminModule file:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home.component';
import { UserComponent } from './user.component';
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'user', component: UserComponent },
{ path: '', component: HomeComponent }
];
@NgModule({
declarations: [
HomeComponent,
UserComponent
],
imports: [
BrowserModule,
RouterModule.forChild(routes)
]
})
export class AdminModule { }
HomeComponent html file:
Home Works!
UserComponent html file:
User Works!
What am I do wrong? Thanks.