1
1
// #docplaster
2
2
// #docregion
3
3
import { NgModule } from '@angular/core' ;
4
- import { RouterModule } from '@angular/router' ;
4
+ import { RouterModule , Routes } from '@angular/router' ;
5
5
6
6
import { AdminComponent } from './admin.component' ;
7
7
import { AdminDashboardComponent } from './admin-dashboard.component' ;
@@ -11,29 +11,31 @@ import { ManageHeroesComponent } from './manage-heroes.component';
11
11
// #docregion admin-route, can-activate-child
12
12
import { AuthGuard } from '../auth-guard.service' ;
13
13
14
- @NgModule ( {
15
- imports : [
16
- RouterModule . forChild ( [
14
+ const adminRoutes : Routes = [
15
+ {
16
+ path : 'admin' ,
17
+ component : AdminComponent ,
18
+ canActivate : [ AuthGuard ] ,
19
+ children : [
17
20
{
18
- path : 'admin' ,
19
- component : AdminComponent ,
20
- canActivate : [ AuthGuard ] ,
21
+ path : '' ,
21
22
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
- ]
23
+ { path : 'crises' , component : ManageCrisesComponent } ,
24
+ { path : 'heroes' , component : ManageHeroesComponent } ,
25
+ { path : '' , component : AdminDashboardComponent }
26
+ ] ,
27
+ // #enddocregion admin-route
28
+ // #docregion can-activate-child
29
+ canActivateChild : [ AuthGuard ]
30
+ // #docregion admin-route
35
31
}
36
- ] )
32
+ ]
33
+ }
34
+ ] ;
35
+
36
+ @NgModule ( {
37
+ imports : [
38
+ RouterModule . forChild ( adminRoutes )
37
39
] ,
38
40
exports : [
39
41
RouterModule
0 commit comments