Skip to content

Instantly share code, notes, and snippets.

@chgc
Created July 11, 2017 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chgc/d4f25d65d779e4a2ba86b96fdcc4ae34 to your computer and use it in GitHub Desktop.
Save chgc/d4f25d65d779e4a2ba86b96fdcc4ae34 to your computer and use it in GitHub Desktop.
nest router-outlet
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {DashboardComponent} from './dashboard/dashboard.component';
import {LayoutComponent} from './dashboard/layout/layout.component';
import {HomeComponent} from './home/home.component';
const routes: Routes = [
{path: '', redirectTo: 'dashboard', pathMatch: 'full'}, {
path: 'dashboard',
component: LayoutComponent,
children: [
{path: '', component: DashboardComponent},
{path: 'home', component: HomeComponent}
]
}
];
@NgModule({imports: [RouterModule.forRoot(routes)], exports: [RouterModule]})
export class AppRoutingModule {
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { HomeComponent } from './home/home.component';
import { LayoutComponent } from './dashboard/layout/layout.component';
@NgModule({
declarations: [
AppComponent,
DashboardComponent,
HomeComponent,
LayoutComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
<p>
layout works!
</p>
<router-outlet></router-outlet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment