Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit e26d998

Browse files
Simplified routing in tutorial example
1 parent 8cf7163 commit e26d998

File tree

9 files changed

+166
-146
lines changed

9 files changed

+166
-146
lines changed

public/docs/_examples/toh-5/ts/app/app-routing.module.1.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

public/docs/_examples/toh-5/ts/app/app-routing.module.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { BrowserModule } from '@angular/platform-browser';
5+
import { FormsModule } from '@angular/forms';
6+
import { RouterModule } from '@angular/router';
7+
8+
import { AppComponent } from './app.component';
9+
import { HeroDetailComponent } from './hero-detail.component';
10+
import { HeroesComponent } from './heroes.component';
11+
import { HeroService } from './hero.service';
12+
13+
@NgModule({
14+
imports: [
15+
BrowserModule,
16+
FormsModule,
17+
RouterModule.forRoot([
18+
{
19+
path: 'heroes',
20+
component: HeroesComponent
21+
}
22+
])
23+
],
24+
declarations: [
25+
AppComponent,
26+
HeroDetailComponent,
27+
HeroesComponent
28+
],
29+
providers: [
30+
HeroService
31+
],
32+
bootstrap: [ AppComponent ]
33+
})
34+
export class AppModule {
35+
}
36+
// #enddocregion
37+
/*
38+
// #docregion heroes, routing
39+
import { RouterModule } from '@angular/router';
40+
41+
RouterModule.forRoot([
42+
{
43+
path: 'heroes',
44+
component: HeroesComponent
45+
}
46+
])
47+
// #enddocregion heroes, routing
48+
*/
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// #docregion
2+
import { NgModule } from '@angular/core';
3+
import { BrowserModule } from '@angular/platform-browser';
4+
import { FormsModule } from '@angular/forms';
5+
import { RouterModule } from '@angular/router';
6+
7+
import { AppComponent } from './app.component';
8+
import { HeroDetailComponent } from './hero-detail.component';
9+
import { DashboardComponent } from './dashboard.component';
10+
import { HeroesComponent } from './heroes.component';
11+
import { HeroService } from './hero.service';
12+
13+
@NgModule({
14+
imports: [
15+
BrowserModule,
16+
FormsModule,
17+
RouterModule.forRoot([
18+
// #docregion redirect
19+
{
20+
path: '',
21+
redirectTo: '/dashboard',
22+
pathMatch: 'full'
23+
},
24+
// #enddocregion redirect
25+
// #docregion dashboard
26+
{
27+
path: 'dashboard',
28+
component: DashboardComponent
29+
},
30+
// #enddocregion dashboard
31+
// #docregion hero-detail
32+
{
33+
path: 'detail/:id',
34+
component: HeroDetailComponent
35+
},
36+
// #enddocregion hero-detail
37+
// #docregion heroes
38+
// #docregion heroes, routing
39+
{
40+
path: 'heroes',
41+
component: HeroesComponent
42+
}
43+
// #enddocregion heroes, routing
44+
])
45+
],
46+
declarations: [
47+
AppComponent,
48+
DashboardComponent,
49+
HeroDetailComponent,
50+
HeroesComponent
51+
],
52+
providers: [
53+
HeroService
54+
],
55+
bootstrap: [ AppComponent ]
56+
})
57+
export class AppModule {
58+
}
59+
// #enddocregion

public/docs/_examples/toh-5/ts/app/app.module.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,37 @@
33
import { NgModule } from '@angular/core';
44
import { BrowserModule } from '@angular/platform-browser';
55
import { FormsModule } from '@angular/forms';
6+
import { RouterModule } from '@angular/router';
67

78
import { AppComponent } from './app.component';
89
import { DashboardComponent } from './dashboard.component';
910
import { HeroDetailComponent } from './hero-detail.component';
1011
import { HeroesComponent } from './heroes.component';
1112
import { HeroService } from './hero.service';
12-
// #docregion routing
13-
import { AppRoutingModule } from './app-routing.module';
14-
// #docregion routing
1513

1614
@NgModule({
1715
imports: [
1816
BrowserModule,
1917
FormsModule,
20-
AppRoutingModule
18+
RouterModule.forRoot([
19+
{
20+
path: '',
21+
redirectTo: '/dashboard',
22+
pathMatch: 'full'
23+
},
24+
{
25+
path: 'dashboard',
26+
component: DashboardComponent
27+
},
28+
{
29+
path: 'detail/:id',
30+
component: HeroDetailComponent
31+
},
32+
{
33+
path: 'heroes',
34+
component: HeroesComponent
35+
}
36+
])
2137
],
2238
// #enddocregion routing
2339
// #docregion dashboard, hero-detail

public/docs/_examples/toh-6/ts/app/app-routing.module.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

public/docs/_examples/toh-6/ts/app/app.module.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { NgModule } from '@angular/core';
99
import { BrowserModule } from '@angular/platform-browser';
1010
import { FormsModule } from '@angular/forms';
1111
import { HttpModule } from '@angular/http';
12+
import { RouterModule } from '@angular/router';
1213

1314
// #enddocregion v1
1415
// Imports for loading & configuring the in-memory web api
@@ -24,7 +25,6 @@ import { HeroService } from './hero.service';
2425
// #enddocregion v1, v2
2526
import { HeroSearchComponent } from './hero-search.component';
2627
// #docregion v1, v2
27-
import { AppRoutingModule } from './app-routing.module';
2828

2929
@NgModule({
3030
imports: [
@@ -36,7 +36,25 @@ import { AppRoutingModule } from './app-routing.module';
3636
InMemoryWebApiModule.forRoot(InMemoryDataService),
3737
// #enddocregion in-mem-web-api
3838
// #docregion v1
39-
AppRoutingModule
39+
RouterModule.forRoot([
40+
{
41+
path: '',
42+
redirectTo: '/dashboard',
43+
pathMatch: 'full'
44+
},
45+
{
46+
path: 'dashboard',
47+
component: DashboardComponent
48+
},
49+
{
50+
path: 'detail/:id',
51+
component: HeroDetailComponent
52+
},
53+
{
54+
path: 'heroes',
55+
component: HeroesComponent
56+
}
57+
])
4058
],
4159
// #docregion search
4260
declarations: [

public/docs/ts/latest/tutorial/_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"toh-pt5": {
2929
"title": "Routing",
30-
"intro": "We add the Angular Component Router and learn to navigate among the views",
30+
"intro": "We add the Angular Router and learn to navigate among the views",
3131
"nextable": true
3232
},
3333
"toh-pt6": {

0 commit comments

Comments
 (0)