Skip to content

Commit 90c643b

Browse files
committed
feat(routing): add a 3rd level of lazy loading
1 parent 44ac444 commit 90c643b

9 files changed

+85
-0
lines changed

src/app/lazy/deep/deep-routing.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { DeepComponent } from './deep.component';
55
export const routes: Routes = [
66
{
77
path: '',
8+
pathMatch: 'full',
89
component: DeepComponent
10+
},
11+
{
12+
path: 'third',
13+
// loadChildren: 'app/lazy/deep/third-level/third-level.module#ThirdLevelModule'
14+
loadChildren: './third-level/third-level.module#ThirdLevelModule'
915
}
1016
];
1117

src/app/lazy/deep/deep.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<p>
22
deep works!
33
</p>
4+
<a routerLink="./third">Go Third Level</a>
5+
<router-outlet></router-outlet>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
import { ThirdLevelComponent } from './third-level.component';
4+
5+
const routes: Routes = [
6+
{
7+
path: '',
8+
component: ThirdLevelComponent
9+
}
10+
];
11+
12+
@NgModule({
13+
imports: [RouterModule.forChild(routes)],
14+
exports: [RouterModule],
15+
providers: []
16+
})
17+
export class ThirdLevelRoutingModule { }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>
2+
third-level works!
3+
</p>

src/app/lazy/deep/third-level/third-level.component.scss

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* tslint:disable:no-unused-variable */
2+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3+
import { By } from '@angular/platform-browser';
4+
import { DebugElement } from '@angular/core';
5+
6+
import { ThirdLevelComponent } from './third-level.component';
7+
8+
describe('ThirdLevelComponent', () => {
9+
let component: ThirdLevelComponent;
10+
let fixture: ComponentFixture<ThirdLevelComponent>;
11+
12+
beforeEach(async(() => {
13+
TestBed.configureTestingModule({
14+
declarations: [ ThirdLevelComponent ]
15+
})
16+
.compileComponents();
17+
}));
18+
19+
beforeEach(() => {
20+
fixture = TestBed.createComponent(ThirdLevelComponent);
21+
component = fixture.componentInstance;
22+
fixture.detectChanges();
23+
});
24+
25+
it('should create', () => {
26+
expect(component).toBeTruthy();
27+
});
28+
});
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-third-level',
5+
templateUrl: './third-level.component.html',
6+
styleUrls: ['./third-level.component.scss']
7+
})
8+
export class ThirdLevelComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { ThirdLevelRoutingModule } from './third-level-routing.module';
4+
import { ThirdLevelComponent } from './third-level.component';
5+
6+
@NgModule({
7+
imports: [
8+
CommonModule,
9+
ThirdLevelRoutingModule
10+
],
11+
declarations: [ThirdLevelComponent]
12+
})
13+
export class ThirdLevelModule { }

src/app/lazy/lazy-routing.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { LazyComponent } from './lazy.component';
55
export const routes: Routes = [
66
{
77
path: '',
8+
pathMatch: 'full',
89
component: LazyComponent
910
},
1011
{

0 commit comments

Comments
 (0)