From 7c5fdffa3027cce651769b51ba73cdda4d3aa0d4 Mon Sep 17 00:00:00 2001
From: Vincent Ogloblinsky <vincent.ogloblinsky@gmail.com>
Date: Wed, 12 Jul 2017 22:43:06 +0200
Subject: [PATCH 1/2] WIP

---
 src/app/about/about-routing.module.ts      |  4 +++-
 src/app/about/compodoc/compodoc.routing.ts |  6 ++++++
 src/app/home/home-routing.module.ts        | 15 +++++++++------
 src/app/home/home.module.ts                |  4 ++--
 4 files changed, 20 insertions(+), 9 deletions(-)
 create mode 100644 src/app/about/compodoc/compodoc.routing.ts

diff --git a/src/app/about/about-routing.module.ts b/src/app/about/about-routing.module.ts
index 63f78c1..aaf7ca9 100644
--- a/src/app/about/about-routing.module.ts
+++ b/src/app/about/about-routing.module.ts
@@ -5,13 +5,15 @@ import { AboutComponent } from './about.component';
 import { TodoMVCComponent } from './todomvc/todomvc.component';
 import { CompodocComponent } from './compodoc/compodoc.component';
 
+import { compodocRoute } from './compodoc/compodoc.routing';
+
 const ABOUT_ROUTES: Routes = [
     {
         path: '', component: AboutComponent,
         children: [
             { path: '', redirectTo: 'todomvc', pathMatch: 'full' },
             { path: 'todomvc', component: TodoMVCComponent },
-            { path: 'compodoc', component: CompodocComponent }
+            ...compodocRoute
         ]
     }
 ];
diff --git a/src/app/about/compodoc/compodoc.routing.ts b/src/app/about/compodoc/compodoc.routing.ts
new file mode 100644
index 0000000..1dfa4b2
--- /dev/null
+++ b/src/app/about/compodoc/compodoc.routing.ts
@@ -0,0 +1,6 @@
+import { Routes } from '@angular/router';
+import { CompodocComponent } from './compodoc.component';
+
+export const compodocRoute: Routes = [
+  { path: 'compodoc', component: CompodocComponent }
+];
diff --git a/src/app/home/home-routing.module.ts b/src/app/home/home-routing.module.ts
index d745022..f5556e1 100644
--- a/src/app/home/home-routing.module.ts
+++ b/src/app/home/home-routing.module.ts
@@ -1,4 +1,4 @@
-import { NgModule } from '@angular/core';
+import { ModuleWithProviders }  from '@angular/core';
 import { Routes, RouterModule } from '@angular/router';
 
 import { HomeComponent } from './home.component';
@@ -7,8 +7,11 @@ const HOME_ROUTES: Routes = [
     { path: 'home', component: HomeComponent }
 ];
 
-@NgModule({
-  imports: [RouterModule.forChild(HOME_ROUTES)],
-  exports: [RouterModule]
-})
-export class HomeRoutingModule {}
+export const HomeRouting: ModuleWithProviders = RouterModule.forChild(HOME_ROUTES);
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
diff --git a/src/app/home/home.module.ts b/src/app/home/home.module.ts
index 346e573..e3e1f2f 100644
--- a/src/app/home/home.module.ts
+++ b/src/app/home/home.module.ts
@@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
 import { HttpModule } from '@angular/http';
 
 import { HomeComponent } from './home.component';
-import { HomeRoutingModule } from './home-routing.module';
+import { HomeRouting } from './home-routing.module';
 
 import { HeaderModule } from '../header/';
 import { ListModule } from '../list/';
@@ -27,7 +27,7 @@ import { FooterModule } from '../footer/';
         HeaderModule,
         ListModule,
         FooterModule,
-        HomeRoutingModule
+        HomeRouting
     ],
     exports: [HomeComponent]
 })

From e74440efbf7618e1ed0395b75e972ed746a1ebd4 Mon Sep 17 00:00:00 2001
From: Vincent Ogloblinsky <vincent.ogloblinsky@gmail.com>
Date: Sun, 16 Jul 2017 15:17:07 +0200
Subject: [PATCH 2/2] Another example

---
 src/app/about/about-routing.module.ts | 4 +++-
 src/app/about/role.ts                 | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 src/app/about/role.ts

diff --git a/src/app/about/about-routing.module.ts b/src/app/about/about-routing.module.ts
index aaf7ca9..466c675 100644
--- a/src/app/about/about-routing.module.ts
+++ b/src/app/about/about-routing.module.ts
@@ -7,12 +7,14 @@ import { CompodocComponent } from './compodoc/compodoc.component';
 
 import { compodocRoute } from './compodoc/compodoc.routing';
 
+import { Role } from './role';
+
 const ABOUT_ROUTES: Routes = [
     {
         path: '', component: AboutComponent,
         children: [
             { path: '', redirectTo: 'todomvc', pathMatch: 'full' },
-            { path: 'todomvc', component: TodoMVCComponent },
+            { path: 'todomvc', component: TodoMVCComponent, data: { requiresLoggedIn: Role.ROLE_ADMIN} },
             ...compodocRoute
         ]
     }
diff --git a/src/app/about/role.ts b/src/app/about/role.ts
new file mode 100644
index 0000000..fae7aeb
--- /dev/null
+++ b/src/app/about/role.ts
@@ -0,0 +1,7 @@
+/**
+ * Role of the app
+ */
+export enum Role {
+    ROLE_ADMIN,
+    ROLE_USER
+}
