Skip to content

Commit 5c2e355

Browse files
committed
add lazy load route example
1 parent 7f13bb0 commit 5c2e355

6 files changed

Lines changed: 44 additions & 2 deletions

File tree

‎src/app/app.module.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
3+
import { RouterModule } from '@angular/router';
34

45
import { AppComponent } from './app.component';
56

@@ -8,7 +9,10 @@ import { AppComponent } from './app.component';
89
AppComponent
910
],
1011
imports: [
11-
BrowserModule
12+
BrowserModule,
13+
RouterModule.forRoot([{
14+
path: '', loadChildren: './home/home.module#HomeModule'
15+
}])
1216
],
1317
providers: [],
1418
bootstrap: [AppComponent]

‎src/app/home/home.component.css‎

Whitespace-only changes.

‎src/app/home/home.component.html‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>
2+
home works!
3+
</p>

‎src/app/home/home.component.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-home',
5+
templateUrl: './home.component.html',
6+
styleUrls: ['./home.component.css']
7+
})
8+
export class HomeComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

‎src/app/home/home.module.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { RouterModule } from '@angular/router';
4+
5+
import { HomeComponent } from './home.component';
6+
7+
@NgModule({
8+
declarations: [
9+
HomeComponent
10+
],
11+
imports: [
12+
CommonModule,
13+
RouterModule.forChild([{
14+
path: '', component: HomeComponent
15+
}])
16+
],
17+
providers: [],
18+
bootstrap: [HomeComponent]
19+
})
20+
export class HomeModule { }

‎src/ui-select/ui-select.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
TEST
1+
<router-outlet></router-outlet>

0 commit comments

Comments
 (0)