Currently my app is fairly simple with only a single module, however I'm looking to expand it with an admin dashboard. From a high-level view, I'm planning on splitting into 2 modules: one for the client-facing site, and an authed lazy admin module like this: Client and admin module diagram
I'm hung up as to how I should setup the header and footer components for these two sections of the site. With a single-module, single-"section" website, it's fairly easy to have a uniform header and footer across the app by placing them in the app-component.html
like so:
<app-header></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>
My issue is that I want a different header and footer component when I'm in the admin section than when I'm on the "main" site.
I've been considering these ideas so far:
Get an isLoggedIn
boolean from an auth-service
to vary the header and footer content based on site section.
In each of the "view" components of the app, manually place in the app-header
and app-footer
components.
Use 3 routing modules: a main-router
, client-router
, and admin-router
. The main router would direct between a app-client-component
and app-admin-component
, with the template contents of each being essentially the above app-component.html
, but the routers would be the client and admin routers respectively.
If anyone has experienced this issue before or has any insight into how I should structure this, it would be much appreciated!
You can create different layouts and reuse them. Your components will know nothing about header and footer - layout selection is in router config. See this link: https://medium.com/angular-in-depth/angular-routing-reusing-common-layout-for-pages-from-different-modules-440a23f86b57