This repository was archived by the owner on Dec 4, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +166
-146
lines changed Expand file tree Collapse file tree 9 files changed +166
-146
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
+ */
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 3
3
import { NgModule } from '@angular/core' ;
4
4
import { BrowserModule } from '@angular/platform-browser' ;
5
5
import { FormsModule } from '@angular/forms' ;
6
+ import { RouterModule } from '@angular/router' ;
6
7
7
8
import { AppComponent } from './app.component' ;
8
9
import { DashboardComponent } from './dashboard.component' ;
9
10
import { HeroDetailComponent } from './hero-detail.component' ;
10
11
import { HeroesComponent } from './heroes.component' ;
11
12
import { HeroService } from './hero.service' ;
12
- // #docregion routing
13
- import { AppRoutingModule } from './app-routing.module' ;
14
- // #docregion routing
15
13
16
14
@NgModule ( {
17
15
imports : [
18
16
BrowserModule ,
19
17
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
+ ] )
21
37
] ,
22
38
// #enddocregion routing
23
39
// #docregion dashboard, hero-detail
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { NgModule } from '@angular/core';
9
9
import { BrowserModule } from '@angular/platform-browser' ;
10
10
import { FormsModule } from '@angular/forms' ;
11
11
import { HttpModule } from '@angular/http' ;
12
+ import { RouterModule } from '@angular/router' ;
12
13
13
14
// #enddocregion v1
14
15
// Imports for loading & configuring the in-memory web api
@@ -24,7 +25,6 @@ import { HeroService } from './hero.service';
24
25
// #enddocregion v1, v2
25
26
import { HeroSearchComponent } from './hero-search.component' ;
26
27
// #docregion v1, v2
27
- import { AppRoutingModule } from './app-routing.module' ;
28
28
29
29
@NgModule ( {
30
30
imports : [
@@ -36,7 +36,25 @@ import { AppRoutingModule } from './app-routing.module';
36
36
InMemoryWebApiModule . forRoot ( InMemoryDataService ) ,
37
37
// #enddocregion in-mem-web-api
38
38
// #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
+ ] )
40
58
] ,
41
59
// #docregion search
42
60
declarations : [
Original file line number Diff line number Diff line change 27
27
},
28
28
"toh-pt5" : {
29
29
"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" ,
31
31
"nextable" : true
32
32
},
33
33
"toh-pt6" : {
You can’t perform that action at this time.
0 commit comments