I am in the process of building a new project for myself. My goal is to create a component that includes a navbar, sidebar, footer, and a page to be displayed as a router.
Below is my app.routing setup:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LayoutComponent } from './layout/layout.component';
import { LoginComponent } from './screens/auth/login/login.component';
import { StatsComponent } from './screens/stats/stats.component';
const appRoutes: Routes = [
{ path: '', component: LoginComponent },
{ path: 'Dashboard', component: LayoutComponent },
{ path: 'login', component: LoginComponent },
{ path: 'stats', component: StatsComponent }
];
@NgModule({
imports: [RouterModule.forRoot(appRoutes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
I have a basic login page which then directs me to the dashboard route.
<h1>Angular Router App</h1>
<nav>
<ul>
<li><a routerLink="/Dashboard/login" routerLinkActive="active">Login</a></li>
</ul>
</nav>
This is my LayoutComponent (Dashboard):
<div class="wrapper">
<div class="app-sidebar" data-active-color="white" data-background-color="black" data-image="assets/img/sidebar-bg/01.jpg">
<p>Sidebar</p>
<div class="sidebar-background"></div>
</div>
<p>NavBar</p>
<div class="main-panel">
<div class="main-content">
<div class="content-wrapper">
<div class="container-fluid">
<router-outlet></router-outlet>
</div>
</div>
</div>
<p>Footer</p>
</div>
</div>
You'll notice I have
<router-outlet></router-outlet>
on this page. I'm looking to understand how I can display another component within this layout. Specifically, I have a component called stats
in my app-routing. How can I show this component within the layout using routing?
For example, something like Dashboard/stats
.