I'm working on an app that displays a form and a list of users. I'm trying to lazy load both of these modules via 2 buttons but the components do not load. I can see form.module.chunk.js and people.module.chunk.js in the network tab in my google developer tools, so the modules are being loaded. I don't have any subfolders in /form or /people if that might be the problem
app-routing-module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MenuComponent } from './menu/menu.component';
const routes: Routes = [
{
path: 'people',
loadChildren: 'app/people/people.module#PeopleModule'
},
{
path: 'form',
loadChildren: 'app/form/form.module#FormModule'
},
{ path: 'menu', component: MenuComponent },
{ path: '', redirectTo: '/menu', pathMatch: 'full' }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Then in the module itself I declared the component
declarations: [PeopleComponent]
and finally this is the code for the routing module
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PeopleComponent } from './people.component';
const routes: Routes = [
{
path: '',
component: PeopleComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class PeopleRoutingModule { }
I'd be happy about any sort of advise
declarations: [PeopleComponent]thisPeopleComponentshould be indeclarationsof one module