I am looking to implement lazy loading, but the user component currently contains a grid displaying all users, and no < router-outlet > .
Consider an app folder such as this:
src
-- app
----user
------user.component.html
------user.component.ts
------userdetail
--------userdetail.component.html
--------userdetail.component.ts
and here are the routes:
{ path: 'user', component: UserComponent },
{ path: 'user/:id', component: UserDetailComponent },
When I switch the structure to the following:
src
-- app
----user
------user-routing.module.ts (new)
------user.component.html
------user.component.ts
------user.module.ts (new)
------userdetail
--------userdetail.component.html
--------userdetail.component.ts
new route:
{ path: 'user', loadChildren: 'app/user/user.module#UserModule'},
the user component lazy loads, but I can't navigate to userdetail, so I plan to move my user grid into a new component 'userlist' and have only < router-outlet > in the 'user' component.
Is it really necessary to have an almost empty component 'user' just for this router outlet? My goal is to lazy load not only the user grid component but user detail component as well.
Here is a plunk I began, but haven't finished yet - https://plnkr.co/edit/m5gYG40wySngiiNpIY7W?p=preview