Skip to content

Commit d2a717e

Browse files
committed
added
1 parent e860de2 commit d2a717e

25 files changed

+227
-20
lines changed
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
<div style="display: flex">
2-
<div><a [routerLink]="['mod1']">Module1</a></div>
3-
<div><a [routerLink]="['mod2']">Module2</a></div>
1+
<div style="display: flex; border: 1px solid black; margin: 20px">
2+
<div style="margin-right: 20px;">MAIN MENU BAR</div>
3+
<div><a [routerLink]="[{outlets: {app_main_outlet: ['mod1'] }}]">Link to lazy Module1</a></div>
4+
<div style="margin: 0 20px">|</div>
5+
<div><a [routerLink]="[{outlets: {app_main_outlet: ['mod2'] }}]">Link to lazy Module2</a></div>
6+
<div style="margin: 0 20px">|</div>
7+
<div><a [routerLink]="[{outlets: {app_side_outlet: ['side1'] }}]">Change to Sidebar1</a></div>
8+
<div style="margin: 0 20px">|</div>
9+
<div><a [routerLink]="[{outlets: {app_side_outlet: ['side2'] }}]">Change to Sidebar2</a></div>
410
</div>

src/app/app.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
<app-app-menu></app-app-menu>
21
<router-outlet></router-outlet>

src/app/app.module.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,27 @@ import { AppComponent } from './app.component';
55
import { AppMenuComponent } from './app-menu/app-menu.component';
66
import {RouterModule, Routes} from '@angular/router';
77
import {Module1Module} from './modules/module1/module1.module';
8+
import { MainComponent } from './main/main.component';
9+
import { Sidebar1Component } from './sidebar1/sidebar1.component';
10+
import { Sidebar2Component } from './sidebar2/sidebar2.component';
811

912
const routes: Routes = [
10-
{path: '', redirectTo: '', pathMatch: 'full' },
11-
{path: 'mod1', loadChildren: './modules/module1/module1.module#Module1Module'},
12-
{path: 'mod2', loadChildren: './modules/module2/module2.module#Module2Module'}
13+
{path: '', redirectTo: 'app', pathMatch: 'full'},
14+
{path: 'app', component: MainComponent, children: [
15+
{path: 'mod1', loadChildren: './modules/module1/module1.module#Module1Module', outlet: 'app_main_outlet'},
16+
{path: 'mod2', loadChildren: './modules/module2/module2.module#Module2Module', outlet: 'app_main_outlet'},
17+
{path: 'side1', component: Sidebar1Component, outlet: 'app_side_outlet'},
18+
{path: 'side2', component: Sidebar2Component, outlet: 'app_side_outlet'}
19+
] }
1320
];
1421

1522
@NgModule({
1623
declarations: [
1724
AppComponent,
18-
AppMenuComponent
25+
AppMenuComponent,
26+
MainComponent,
27+
Sidebar1Component,
28+
Sidebar2Component
1929
],
2030
imports: [
2131
BrowserModule,

src/app/main/main.component.css

Whitespace-only changes.

src/app/main/main.component.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div>
2+
<app-app-menu></app-app-menu>
3+
</div>
4+
<div style="display: flex">
5+
<div style="flex-grow: 1;border: 1px solid black; min-height: 300px;margin-right: 10px;">
6+
<router-outlet name="app_main_outlet"></router-outlet>
7+
</div>
8+
<div style="width: 200px; border: 1px solid black; min-height: 300px">
9+
<div>SIDEBAR</div>
10+
<router-outlet name="app_side_outlet"></router-outlet>
11+
</div>
12+
</div>

src/app/main/main.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { MainComponent } from './main.component';
4+
5+
describe('MainComponent', () => {
6+
let component: MainComponent;
7+
let fixture: ComponentFixture<MainComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ MainComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(MainComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

src/app/main/main.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-main',
5+
templateUrl: './main.component.html',
6+
styleUrls: ['./main.component.css']
7+
})
8+
export class MainComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<div style="display: flex;">
2-
<a [routerLink]="[{outlets:{'main':['screen1']}}]">screen1</a>|
1+
<div style="display: flex; border: 1px solid blue; margin: 20px;">
2+
<div style="margin-right: 20px;">Lazy Module 1 Menu Bar</div>
3+
<a [routerLink]="[{outlets:{'main':['screen1']}}]">screen1</a>
4+
<div style="margin: 0 20px;">|</div>
35
<a [routerLink]="[{outlets:{main:'screen2'}}]">screen2</a>
46
</div>
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<div>
22
<app-mod1-menu></app-mod1-menu>
33
</div>
4-
5-
<div>^router-outlet------------------------------------------------\/main-outlet</div>
6-
<div>
7-
<router-outlet name="main"></router-outlet>
4+
<div>module outlet below</div>
5+
<div style="border: 1px solid blue; margin: 20px">
6+
<router-outlet name="main">Choose screen1 or 2</router-outlet>
87
</div>

src/app/modules/module1/module1-routing.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { Module1MainComponent } from './module1-main/module1-main.component';
44
import { Screen1Component } from './screen1/screen1.component';
55
import { Screen2Component } from './screen2/screen2.component';
66
import {Sec1Component} from './sec1/sec1.component';
7+
import {Sec2Component} from './sec2/sec2.component';
78

89
const routes: Routes = [
910
{path: '', redirectTo: 'lm'},
1011
{
1112
path: 'lm', component: Module1MainComponent, children: [
1213
{path: 'screen1', component: Screen1Component, outlet: 'main', children: [
13-
{path: 'sec1', component: Sec1Component, outlet: 'sec1_out'}
14+
{path: 'sec1', component: Sec1Component, outlet: 'screen1_out'},
15+
{path: 'sec2', component: Sec2Component, outlet: 'screen1_out'}
1416
]},
1517
{path: 'screen2', component: Screen2Component, outlet: 'main'}
1618
]}

src/app/modules/module1/module1.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import { Mod1MenuComponent } from './mod1-menu/mod1-menu.component';
77
import { Screen1Component } from './screen1/screen1.component';
88
import { Screen2Component } from './screen2/screen2.component';
99
import { Sec1Component } from './sec1/sec1.component';
10+
import { Sec2Component } from './sec2/sec2.component';
1011

1112
@NgModule({
1213
imports: [
1314
CommonModule,
1415
Module1RoutingModule
1516
],
16-
declarations: [Module1MainComponent, Mod1MenuComponent, Screen1Component, Screen2Component, Sec1Component]
17+
declarations: [Module1MainComponent, Mod1MenuComponent, Screen1Component, Screen2Component, Sec1Component, Sec2Component]
1718
})
1819
export class Module1Module { }
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
<div><a [routerLink]="[{outlets: {sec1_out: ['sec1']}}]">Section1</a>
2-
<router-outlet name="sec1_out"></router-outlet>
1+
<div style="border: 1px solid green; margin: 20px">
2+
<a [routerLink]="[{outlets: {screen1_out: ['sec1']}}]" style="margin: 20px">Section1</a>
3+
<a [routerLink]="[{outlets: {screen1_out: ['sec2']}}]">Section2</a>
4+
<div>Inner router Outlet below</div>
5+
<router-outlet name="screen1_out"></router-outlet>
36
</div>
4-
<div>-------------</div>
5-
<div>Section2
7+
8+
<div style="border: 1px solid green; margin: 20px">Section2
9+
<div>(not used) Inner router Outlet below</div>
610
<router-outlet name="sec2"></router-outlet>
711
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<p>
22
screen2 works!
33
</p>
4+
<div>
5+
6+
</div>

src/app/modules/module1/sec2/sec2.component.css

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>
2+
sec2 works!
3+
</p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { Sec2Component } from './sec2.component';
4+
5+
describe('Sec2Component', () => {
6+
let component: Sec2Component;
7+
let fixture: ComponentFixture<Sec2Component>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ Sec2Component ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(Sec2Component);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
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-sec2',
5+
templateUrl: './sec2.component.html',
6+
styleUrls: ['./sec2.component.css']
7+
})
8+
export class Sec2Component implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

src/app/sidebar1/sidebar1.component.css

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>
2+
sidebar1 works!
3+
</p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { Sidebar1Component } from './sidebar1.component';
4+
5+
describe('Sidebar1Component', () => {
6+
let component: Sidebar1Component;
7+
let fixture: ComponentFixture<Sidebar1Component>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ Sidebar1Component ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(Sidebar1Component);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
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-sidebar1',
5+
templateUrl: './sidebar1.component.html',
6+
styleUrls: ['./sidebar1.component.css']
7+
})
8+
export class Sidebar1Component implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

src/app/sidebar2/sidebar2.component.css

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>
2+
sidebar2 works!
3+
</p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { Sidebar2Component } from './sidebar2.component';
4+
5+
describe('Sidebar2Component', () => {
6+
let component: Sidebar2Component;
7+
let fixture: ComponentFixture<Sidebar2Component>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ Sidebar2Component ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(Sidebar2Component);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
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-sidebar2',
5+
templateUrl: './sidebar2.component.html',
6+
styleUrls: ['./sidebar2.component.css']
7+
})
8+
export class Sidebar2Component implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

0 commit comments

Comments
 (0)