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

Commit aa17db4

Browse files
Updated router dev guide with routing modules
1 parent e26d998 commit aa17db4

Some content is hidden

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

42 files changed

+895
-634
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
import { AdminComponent } from './admin.component';
7+
import { AdminDashboardComponent } from './admin-dashboard.component';
8+
import { ManageCrisesComponent } from './manage-crises.component';
9+
import { ManageHeroesComponent } from './manage-heroes.component';
10+
11+
// #docregion admin-routes
12+
@NgModule({
13+
imports: [
14+
RouterModule.forChild([
15+
{
16+
path: 'admin',
17+
component: AdminComponent,
18+
children: [
19+
{
20+
path: '',
21+
children: [
22+
{ path: 'crises', component: ManageCrisesComponent },
23+
{ path: 'heroes', component: ManageHeroesComponent },
24+
{ path: '', component: AdminDashboardComponent }
25+
]
26+
}
27+
]
28+
}
29+
])
30+
],
31+
exports: [
32+
RouterModule
33+
]
34+
})
35+
export class AdminRoutingModule {}
36+
// #enddocregion admin-routes
37+
// #enddocregion
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
import { AdminComponent } from './admin.component';
7+
import { AdminDashboardComponent } from './admin-dashboard.component';
8+
import { ManageCrisesComponent } from './manage-crises.component';
9+
import { ManageHeroesComponent } from './manage-heroes.component';
10+
11+
// #docregion admin-route, can-activate-child
12+
import { AuthGuard } from '../auth-guard.service';
13+
14+
@NgModule({
15+
imports: [
16+
RouterModule.forChild([
17+
{
18+
path: 'admin',
19+
component: AdminComponent,
20+
canActivate: [AuthGuard],
21+
children: [
22+
{
23+
path: '',
24+
children: [
25+
{ path: 'crises', component: ManageCrisesComponent },
26+
{ path: 'heroes', component: ManageHeroesComponent },
27+
{ path: '', component: AdminDashboardComponent }
28+
],
29+
// #enddocregion admin-route
30+
// #docregion can-activate-child
31+
canActivateChild: [AuthGuard]
32+
// #docregion admin-route
33+
}
34+
]
35+
}
36+
])
37+
],
38+
exports: [
39+
RouterModule
40+
]
41+
})
42+
export class AdminRoutingModule {}
43+
// #enddocregion
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
import { AdminComponent } from './admin.component';
7+
import { AdminDashboardComponent } from './admin-dashboard.component';
8+
import { ManageCrisesComponent } from './manage-crises.component';
9+
import { ManageHeroesComponent } from './manage-heroes.component';
10+
11+
// #docregion admin-route
12+
import { AuthGuard } from '../auth-guard.service';
13+
14+
// #docregion can-activate-child
15+
@NgModule({
16+
imports: [
17+
RouterModule.forChild([
18+
{
19+
path: 'admin',
20+
component: AdminComponent,
21+
canActivate: [AuthGuard],
22+
children: [
23+
{
24+
path: '',
25+
canActivateChild: [AuthGuard],
26+
children: [
27+
{ path: 'crises', component: ManageCrisesComponent },
28+
{ path: 'heroes', component: ManageHeroesComponent },
29+
{ path: '', component: AdminDashboardComponent }
30+
]
31+
}
32+
]
33+
}
34+
])
35+
],
36+
exports: [
37+
RouterModule
38+
]
39+
})
40+
export class AdminRoutingModule {}
41+
// #enddocregion
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
import { AdminComponent } from './admin.component';
7+
import { AdminDashboardComponent } from './admin-dashboard.component';
8+
import { ManageCrisesComponent } from './manage-crises.component';
9+
import { ManageHeroesComponent } from './manage-heroes.component';
10+
11+
// #docregion admin-route
12+
import { AuthGuard } from '../auth-guard.service';
13+
14+
@NgModule({
15+
imports: [
16+
RouterModule.forChild([
17+
{
18+
path: '',
19+
component: AdminComponent,
20+
canActivate: [AuthGuard],
21+
children: [
22+
{
23+
path: '',
24+
canActivateChild: [AuthGuard],
25+
children: [
26+
{ path: 'crises', component: ManageCrisesComponent },
27+
{ path: 'heroes', component: ManageHeroesComponent },
28+
{ path: '', component: AdminDashboardComponent }
29+
]
30+
}
31+
]
32+
}
33+
])
34+
],
35+
exports: [
36+
RouterModule
37+
]
38+
})
39+
export class AdminRoutingModule {}
40+
// #enddocregion

public/docs/_examples/router/ts/app/admin/admin.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { AdminDashboardComponent } from './admin-dashboard.component';
88
import { ManageCrisesComponent } from './manage-crises.component';
99
import { ManageHeroesComponent } from './manage-heroes.component';
1010

11-
import { adminRouting } from './admin.routing';
11+
import { AdminRoutingModule } from './admin-routing.module';
1212

1313
@NgModule({
1414
imports: [
1515
CommonModule,
16-
adminRouting
16+
AdminRoutingModule
1717
],
1818
declarations: [
1919
AdminComponent,

public/docs/_examples/router/ts/app/admin/admin.routing.1.ts

-31
This file was deleted.

public/docs/_examples/router/ts/app/admin/admin.routing.2.ts

-37
This file was deleted.

public/docs/_examples/router/ts/app/admin/admin.routing.3.ts

-35
This file was deleted.

public/docs/_examples/router/ts/app/admin/admin.routing.ts

-34
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
import { CrisisListComponent } from './crisis-list.component';
7+
import { HeroListComponent } from './hero-list.component';
8+
9+
@NgModule({
10+
imports: [
11+
RouterModule.forRoot([
12+
{ path: 'crisis-center', component: CrisisListComponent },
13+
{ path: 'heroes', component: HeroListComponent }
14+
])
15+
],
16+
exports: [
17+
RouterModule
18+
]
19+
})
20+
export class AppRoutingModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
import { CrisisListComponent } from './crisis-list.component';
7+
8+
@NgModule({
9+
imports: [
10+
RouterModule.forRoot([
11+
{ path: 'crisis-center', component: CrisisListComponent },
12+
])
13+
],
14+
exports: [
15+
RouterModule
16+
]
17+
})
18+
export class AppRoutingModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
@NgModule({
7+
imports: [
8+
RouterModule.forRoot([
9+
10+
])
11+
],
12+
exports: [
13+
RouterModule
14+
]
15+
})
16+
export class AppRoutingModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// #docplaster
2+
// #docregion
3+
import { NgModule } from '@angular/core';
4+
import { RouterModule } from '@angular/router';
5+
6+
@NgModule({
7+
imports: [
8+
RouterModule.forRoot([
9+
10+
])
11+
],
12+
exports: [
13+
RouterModule
14+
]
15+
})
16+
export class AppRoutingModule {}

0 commit comments

Comments
 (0)