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

Commit ff11881

Browse files
brandonrobertswardbell
authored andcommitted
docs(router): Updated routing examples to use routing modules (#2478)
Simplified routing in tutorial example Updated ngmodule guide and ngmodule faq with routing module prose
1 parent 3a78f6d commit ff11881

File tree

81 files changed

+1600
-1216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1600
-1216
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion
2-
import { ModuleWithProviders } from '@angular/core';
2+
import { NgModule } from '@angular/core';
33
import { Routes, RouterModule } from '@angular/router';
44

55
import { MovieListComponent } from './movie-list.component';
@@ -9,4 +9,8 @@ const routes: Routes = [
99
{ path: 'movies', component: MovieListComponent }
1010
];
1111

12-
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
12+
@NgModule({
13+
imports: [RouterModule.forRoot(routes)],
14+
exports: [RouterModule]
15+
})
16+
export class AppRoutingModule {}

public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { FormsModule } from '@angular/forms';
55

66
import { AppComponent } from './app.component';
77
import { MovieListComponent } from './movie-list.component';
8-
import { routing } from './app.routing';
8+
import { AppRoutingModule } from './app-routing.module';
99

1010
@NgModule({
1111
imports: [
1212
BrowserModule,
1313
FormsModule,
14-
routing
14+
AppRoutingModule
1515
],
1616
declarations: [
1717
AppComponent,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
const routes: Routes = [];
5+
6+
@NgModule({
7+
imports: [RouterModule.forRoot(routes)],
8+
providers: [],
9+
exports: [RouterModule]
10+
})
11+
export class AppRoutingModule {}

public/docs/_examples/cb-dependency-injection/ts/app/app.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';
33
import { FormsModule } from '@angular/forms';
44
import { HttpModule } from '@angular/http';
55

6-
/* import { routing } from './app.routing';*/
6+
// import { AppRoutingModule } from './app-routing.module';
77
import { LocationStrategy,
88
HashLocationStrategy } from '@angular/common';
99
import { NgModule } from '@angular/core';
@@ -56,7 +56,7 @@ const c_components = [
5656
FormsModule,
5757
HttpModule,
5858
InMemoryWebApiModule.forRoot(HeroData)
59-
// routing TODO: add routes
59+
// AppRoutingModule TODO: add routes
6060
],
6161
declarations: [
6262
declarations,

public/docs/_examples/cb-dependency-injection/ts/app/app.routing.ts

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModuleWithProviders } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
33

44
export const routes: Routes = [
@@ -7,4 +7,8 @@ export const routes: Routes = [
77
{ path: 'heroes', loadChildren: 'app/hero/hero.module.3#HeroModule' }
88
];
99

10-
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
10+
@NgModule({
11+
imports: [RouterModule.forRoot(routes)],
12+
exports: [RouterModule]
13+
})
14+
export class AppRoutingModule {}

public/docs/_examples/ngmodule/ts/app/app.routing.ts renamed to public/docs/_examples/ngmodule/ts/app/app-routing.module.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion
2-
import { ModuleWithProviders } from '@angular/core';
2+
import { NgModule } from '@angular/core';
33
import { Routes, RouterModule } from '@angular/router';
44

55
export const routes: Routes = [
@@ -11,5 +11,9 @@ export const routes: Routes = [
1111
];
1212

1313
// #docregion forRoot
14-
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
14+
@NgModule({
15+
imports: [RouterModule.forRoot(routes)],
16+
exports: [RouterModule]
17+
})
18+
export class AppRoutingModule {}
1519
// #enddocregion forRoot

public/docs/_examples/ngmodule/ts/app/app.module.3.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ import { UserService } from './user.service';
1111

1212
/* Feature Modules */
1313
import { ContactModule } from './contact/contact.module.3';
14-
import { routing } from './app.routing.3';
14+
15+
/* Routing Module */
16+
import { AppRoutingModule } from './app-routing.module.3';
1517

1618
@NgModule({
1719
// #docregion imports
1820
imports: [
1921
BrowserModule,
2022
ContactModule,
21-
routing
23+
AppRoutingModule
2224
],
2325
// #enddocregion imports
2426
providers: [ UserService ],

public/docs/_examples/ngmodule/ts/app/app.module.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import { BrowserModule } from '@angular/platform-browser';
88
import { AppComponent } from './app.component';
99

1010
/* Feature Modules */
11-
import { ContactModule } from './contact/contact.module';
12-
import { CoreModule } from './core/core.module';
13-
import { routing } from './app.routing';
11+
import { ContactModule } from './contact/contact.module';
12+
import { CoreModule } from './core/core.module';
13+
14+
/* Routing Module */
15+
import { AppRoutingModule } from './app-routing.module';
1416

1517
@NgModule({
1618
// #docregion import-for-root
@@ -29,7 +31,7 @@ import { routing } from './app.routing';
2931
// #docregion
3032
CoreModule.forRoot({userName: 'Miss Marple'}),
3133
// #docregion v4
32-
routing
34+
AppRoutingModule
3335
],
3436
// #enddocregion import-for-root
3537
declarations: [ AppComponent ],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
4+
import { ContactComponent } from './contact.component.3';
5+
6+
@NgModule({
7+
imports: [RouterModule.forChild([
8+
{ path: 'contact', component: ContactComponent}
9+
])],
10+
exports: [RouterModule]
11+
})
12+
export class ContactRoutingModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
4+
import { ContactComponent } from './contact.component';
5+
6+
// #docregion routing
7+
@NgModule({
8+
imports: [RouterModule.forChild([
9+
{ path: 'contact', component: ContactComponent }
10+
])],
11+
exports: [RouterModule]
12+
})
13+
export class ContactRoutingModule {}
14+
// #enddocregion

public/docs/_examples/ngmodule/ts/app/contact/contact.module.3.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import { ContactComponent } from './contact.component.3';
99
import { ContactService } from './contact.service';
1010
import { HighlightDirective } from './highlight.directive';
1111

12-
import { routing } from './contact.routing.3';
12+
import { ContactRoutingModule } from './contact-routing.module.3';
1313

1414
// #docregion class
1515
@NgModule({
16-
imports: [ CommonModule, FormsModule, routing ],
16+
imports: [ CommonModule, FormsModule, ContactRoutingModule ],
1717
declarations: [ ContactComponent, HighlightDirective, AwesomePipe ],
1818
providers: [ ContactService ]
1919
})

public/docs/_examples/ngmodule/ts/app/contact/contact.module.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import { NgModule } from '@angular/core';
33
import { SharedModule } from '../shared/shared.module';
44

5-
import { ContactComponent } from './contact.component';
6-
import { ContactService } from './contact.service';
7-
import { routing } from './contact.routing';
5+
import { ContactComponent } from './contact.component';
6+
import { ContactService } from './contact.service';
7+
import { ContactRoutingModule } from './contact-routing.module';
88

99
// #docregion class
1010
@NgModule({
11-
imports: [ SharedModule, routing ],
11+
imports: [ SharedModule, ContactRoutingModule ],
1212
declarations: [ ContactComponent ],
1313
providers: [ ContactService ]
1414
})

public/docs/_examples/ngmodule/ts/app/contact/contact.routing.3.ts

-8
This file was deleted.

public/docs/_examples/ngmodule/ts/app/contact/contact.routing.ts

-10
This file was deleted.

public/docs/_examples/ngmodule/ts/app/crisis/crisis.routing.ts renamed to public/docs/_examples/ngmodule/ts/app/crisis/crisis-routing.module.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModuleWithProviders } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { Routes,
33
RouterModule } from '@angular/router';
44

@@ -11,4 +11,8 @@ const routes: Routes = [
1111
{ path: ':id', component: CrisisDetailComponent }
1212
];
1313

14-
export const routing: ModuleWithProviders = RouterModule.forChild(routes);
14+
@NgModule({
15+
imports: [RouterModule.forChild(routes)],
16+
exports: [RouterModule]
17+
})
18+
export class CrisisRoutingModule {}

public/docs/_examples/ngmodule/ts/app/crisis/crisis.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { CommonModule } from '@angular/common';
33

44
import { CrisisListComponent } from './crisis-list.component';
55
import { CrisisDetailComponent } from './crisis-detail.component';
6-
import { CrisisService } from './crisis.service';
7-
import { routing } from './crisis.routing';
6+
import { CrisisService } from './crisis.service';
7+
import { CrisisRoutingModule } from './crisis-routing.module';
88

99
@NgModule({
10-
imports: [ CommonModule, routing ],
10+
imports: [ CommonModule, CrisisRoutingModule ],
1111
declarations: [ CrisisDetailComponent, CrisisListComponent ],
1212
providers: [ CrisisService ]
1313
})

public/docs/_examples/ngmodule/ts/app/hero/hero.routing.3.ts renamed to public/docs/_examples/ngmodule/ts/app/hero/hero-routing.module.3.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModuleWithProviders } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { Routes,
33
RouterModule } from '@angular/router';
44

@@ -16,4 +16,8 @@ const routes: Routes = [
1616
}
1717
];
1818

19-
export const routing: ModuleWithProviders = RouterModule.forChild(routes);
19+
@NgModule({
20+
imports: [RouterModule.forChild(routes)],
21+
exports: [RouterModule]
22+
})
23+
export class HeroRoutingModule {}

public/docs/_examples/ngmodule/ts/app/hero/hero.routing.ts renamed to public/docs/_examples/ngmodule/ts/app/hero/hero-routing.module.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModuleWithProviders } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { Routes,
33
RouterModule } from '@angular/router';
44

@@ -16,4 +16,8 @@ const routes: Routes = [
1616
}
1717
];
1818

19-
export const routing: ModuleWithProviders = RouterModule.forChild(routes);
19+
@NgModule({
20+
imports: [RouterModule.forChild(routes)],
21+
exports: [RouterModule]
22+
})
23+
export class HeroRoutingModule {}

public/docs/_examples/ngmodule/ts/app/hero/hero.module.3.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { HeroComponent } from './hero.component.3';
66
import { HeroDetailComponent } from './hero-detail.component';
77
import { HeroListComponent } from './hero-list.component';
88
import { HighlightDirective } from './highlight.directive';
9-
import { routing } from './hero.routing.3';
9+
import { HeroRoutingModule } from './hero-routing.module.3';
1010

1111
// #docregion class
1212
@NgModule({
13-
imports: [ CommonModule, FormsModule, routing ],
13+
imports: [ CommonModule, FormsModule, HeroRoutingModule ],
1414
declarations: [
1515
HeroComponent, HeroDetailComponent, HeroListComponent,
1616
HighlightDirective

public/docs/_examples/ngmodule/ts/app/hero/hero.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { SharedModule } from '../shared/shared.module';
55
import { HeroComponent } from './hero.component';
66
import { HeroDetailComponent } from './hero-detail.component';
77
import { HeroListComponent } from './hero-list.component';
8-
import { routing } from './hero.routing';
8+
import { HeroRoutingModule } from './hero-routing.module';
99

1010
@NgModule({
11-
imports: [ SharedModule, routing ],
11+
imports: [ SharedModule, HeroRoutingModule ],
1212
declarations: [
1313
HeroComponent, HeroDetailComponent, HeroListComponent,
1414
]

public/docs/_examples/ngmodule/ts/plnkr.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": [
44
"app/app.component.ts",
55
"app/app.module.ts",
6-
"app/app.routing.ts",
6+
"app/app-routing.module.ts",
77
"app/main.ts",
88

99
"app/contact/contact.component.css",
@@ -12,7 +12,7 @@
1212

1313
"app/contact/contact.component.ts",
1414
"app/contact/contact.module.ts",
15-
"app/contact/contact.routing.ts",
15+
"app/contact/contact-routing.module.ts",
1616

1717
"app/crisis/*.ts",
1818

@@ -22,7 +22,7 @@
2222

2323
"app/hero/hero.component.ts",
2424
"app/hero/hero.module.ts",
25-
"app/hero/hero.routing.ts",
25+
"app/hero/hero-routing.module.ts",
2626

2727
"app/core/*.css",
2828
"app/core/*.html",

public/docs/_examples/ngmodule/ts/pre-shared.3.plnkr.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": [
44
"app/app.component.3.ts",
55
"app/app.module.3.ts",
6-
"app/app.routing.3.ts",
6+
"app/app-routing.module.3.ts",
77
"app/main.3.ts",
88

99
"app/highlight.directive.ts",
@@ -18,7 +18,7 @@
1818
"app/contact/awesome.pipe.ts",
1919
"app/contact/contact.component.3.ts",
2020
"app/contact/contact.module.3.ts",
21-
"app/contact/contact.routing.3.ts",
21+
"app/contact/contact-routing.module.3.ts",
2222
"app/contact/highlight.directive.ts",
2323

2424
"app/crisis/*.ts",
@@ -29,7 +29,7 @@
2929

3030
"app/hero/hero.component.3.ts",
3131
"app/hero/hero.module.3.ts",
32-
"app/hero/hero.routing.3.ts",
32+
"app/hero/hero-routing.module.3.ts",
3333
"app/hero/highlight.directive.ts",
3434

3535
"styles.css",

0 commit comments

Comments
 (0)