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

Lines changed: 2 additions & 2 deletions
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,
Lines changed: 11 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 10 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 6 additions & 4 deletions
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 ],
Lines changed: 12 additions & 0 deletions
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 {}

0 commit comments

Comments
 (0)