Skip to content

Commit bace6ca

Browse files
authored
Merge pull request #1 from pradeep0601/feature
code changes for routing
2 parents 9f91da8 + 0c83200 commit bace6ca

18 files changed

+193
-27
lines changed

e2e/app.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ describe('angular5-router-app App', () => {
99

1010
it('should display welcome message', () => {
1111
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('Welcome to app!');
12+
expect(page.getParagraphText()).toEqual('Welcome to Angular5 Router Sample Application!!!');
1313
});
1414
});

src/app/app.component.html

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
<!--The content below is only a placeholder and can be replaced.-->
21
<div style="text-align:center">
32
<h1>
4-
Welcome to {{ title }}!
3+
Welcome to {{title}}!!
54
</h1>
6-
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
7-
</div>
8-
<h2>Here are some links to help you start: </h2>
9-
<ul>
10-
<li>
11-
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
12-
</li>
13-
<li>
14-
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
15-
</li>
16-
<li>
17-
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
18-
</li>
19-
</ul>
20-
5+
<nav>
6+
<a routerLink="home" routerLinkActive="active">Home</a>
7+
<a routerLink="about">About</a>
8+
<a routerLink="dashboard">Dashboard</a>
9+
</nav>
10+
<router-outlet></router-outlet>
11+
</div>

src/app/app.component.spec.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
11
import { TestBed, async } from '@angular/core/testing';
22
import { AppComponent } from './app.component';
3+
import { HomeComponent } from './components/home/home.component';
4+
import { AboutComponent } from './components/about/about.component';
5+
import { DashboardComponent } from './components/dashboard/dashboard.component';
6+
import { RouterModule } from '@angular/router';
7+
import { appRoutes } from "./routerConfig";
8+
import { APP_BASE_HREF } from '@angular/common';
9+
310
describe('AppComponent', () => {
411
beforeEach(async(() => {
512
TestBed.configureTestingModule({
613
declarations: [
7-
AppComponent
14+
AppComponent,
15+
HomeComponent,
16+
AboutComponent,
17+
DashboardComponent
818
],
19+
imports: [
20+
RouterModule.forRoot(appRoutes)
21+
],
22+
providers: [
23+
{ provide: APP_BASE_HREF, useValue: '/' }
24+
]
925
}).compileComponents();
1026
}));
1127
it('should create the app', async(() => {
1228
const fixture = TestBed.createComponent(AppComponent);
1329
const app = fixture.debugElement.componentInstance;
1430
expect(app).toBeTruthy();
1531
}));
16-
it(`should have as title 'app'`, async(() => {
32+
it(`should have as title 'Angular5 Router Sample Application!'`, async(() => {
1733
const fixture = TestBed.createComponent(AppComponent);
1834
const app = fixture.debugElement.componentInstance;
19-
expect(app.title).toEqual('app');
35+
expect(app.title).toEqual('Angular5 Router Sample Application!');
2036
}));
2137
it('should render title in a h1 tag', async(() => {
2238
const fixture = TestBed.createComponent(AppComponent);
2339
fixture.detectChanges();
2440
const compiled = fixture.debugElement.nativeElement;
25-
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
41+
expect(compiled.querySelector('h1').textContent).toContain('Angular5 Router Sample Application!');
2642
}));
2743
});

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import { Component } from '@angular/core';
66
styleUrls: ['./app.component.css']
77
})
88
export class AppComponent {
9-
title = 'app';
9+
title = 'Angular5 Router Sample Application!';
1010
}

src/app/app.module.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
import { BrowserModule } from '@angular/platform-browser';
2+
import { RouterModule } from '@angular/router';
23
import { NgModule } from '@angular/core';
3-
4+
import { appRoutes } from "./routerConfig";
45

56
import { AppComponent } from './app.component';
6-
7+
import { HomeComponent } from './components/home/home.component';
8+
import { AboutComponent } from './components/about/about.component';
9+
import { DashboardComponent } from './components/dashboard/dashboard.component';
710

811
@NgModule({
912
declarations: [
10-
AppComponent
13+
AppComponent,
14+
HomeComponent,
15+
AboutComponent,
16+
DashboardComponent
1117
],
1218
imports: [
13-
BrowserModule
19+
BrowserModule,
20+
RouterModule.forRoot(appRoutes)
21+
],
22+
exports:[
23+
RouterModule,
24+
HomeComponent,
25+
AboutComponent,
26+
DashboardComponent
1427
],
1528
providers: [],
1629
bootstrap: [AppComponent]

src/app/components/about/about.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+
about 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 { 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+
});
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.css']
7+
})
8+
export class AboutComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

src/app/components/dashboard/dashboard.component.css

Whitespace-only changes.

0 commit comments

Comments
 (0)