Skip to content

Commit 9e4fc46

Browse files
authored
Merge pull request #11 from brunolm/feature/more-modules
Add modules, components, routes
2 parents 42be910 + 0c66393 commit 9e4fc46

30 files changed

+349
-12
lines changed

src/app/about/about.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="container">
2+
<p>
3+
This project shows you how to do things in Angular with full diff examples in commits/pull requests, with instructions included.
4+
</p>
5+
</div>

src/app/about/about.component.scss

Whitespace-only changes.
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 { AboutComponent } from './about.component';
4+
5+
describe('AboutComponent', () => {
6+
let component: AboutComponent;
7+
let fixture: ComponentFixture<AboutComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ AboutComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(AboutComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

src/app/about/about.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-about',
5+
templateUrl: './about.component.html',
6+
styleUrls: ['./about.component.scss']
7+
})
8+
export class AboutComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

src/app/about/about.module.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { AboutModule } from './about.module';
2+
3+
describe('AboutModule', () => {
4+
let aboutModule: AboutModule;
5+
6+
beforeEach(() => {
7+
aboutModule = new AboutModule();
8+
});
9+
10+
it('should create an instance', () => {
11+
expect(aboutModule).toBeTruthy();
12+
});
13+
});

src/app/about/about.module.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
4+
import { AboutComponent } from './about.component';
5+
import { RoutingModule } from './about.router';
6+
7+
@NgModule({
8+
imports: [RoutingModule, CommonModule],
9+
declarations: [AboutComponent],
10+
})
11+
export class AboutModule {}

src/app/about/about.router.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { RouterModule, Routes } from '@angular/router';
2+
3+
import { AboutComponent } from './about.component';
4+
5+
const routes: Routes = [
6+
{
7+
path: '',
8+
component: AboutComponent,
9+
},
10+
];
11+
12+
export const RoutingModule = RouterModule.forChild(routes);

src/app/app.component.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ <h1>
1010
</div>
1111
</div>
1212

13+
<nav>
14+
<ul>
15+
<li><a routerLink="about" routerLinkActive="active">About</a></li>
16+
<li><a routerLink="contact" routerLinkActive="active">Contact</a></li>
17+
<li><a routerLink="heroes" routerLinkActive="active">Heroes</a></li>
18+
<li><a routerLink="tutorials" routerLinkActive="active">Tutorials</a></li>
19+
</ul>
20+
</nav>
1321
<hr />
1422

1523
<router-outlet></router-outlet>

src/app/app.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
nav {
2+
a {
3+
&.active {
4+
font-weight: bold;
5+
}
6+
}
7+
}

src/app/app.router.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { NgModule } from '@angular/core';
2-
import { Routes, RouterModule } from '@angular/router';
1+
import { RouterModule, Routes } from '@angular/router';
2+
33
import { LayoutComponent } from './shared/layout/layout.component';
44

55
const routes: Routes = [
@@ -8,9 +8,25 @@ const routes: Routes = [
88
{
99
path: '',
1010
component: LayoutComponent,
11-
children: [
12-
{ path: 'tutorials', loadChildren: 'app/tutorials/tutorials.module#TutorialsModule' },
13-
],
11+
children: [{ path: 'about', loadChildren: 'app/about/about.module#AboutModule' }],
12+
},
13+
14+
{
15+
path: '',
16+
component: LayoutComponent,
17+
children: [{ path: 'contact', loadChildren: 'app/contact/contact.module#ContactModule' }],
18+
},
19+
20+
{
21+
path: '',
22+
component: LayoutComponent,
23+
children: [{ path: 'heroes', loadChildren: 'app/heroes/heroes.module#HeroesModule' }],
24+
},
25+
26+
{
27+
path: '',
28+
component: LayoutComponent,
29+
children: [{ path: 'tutorials', loadChildren: 'app/tutorials/tutorials.module#TutorialsModule' }],
1430
},
1531
];
1632

0 commit comments

Comments
 (0)