title: Routing between modules in Angular 2
body: <p>I'm writing an application where all features got it's own module (A feature could be a page, or a part of a page). This because we want all features to have it's own domain logic, services, directives and components, i.e. in the dashboard module we got an ChartComponent widget that I don't want to expose to other views like login or profile.</p>
  
  <p>The problem is when working with routing in Angular 2 you always routes to a particular component, not a module.</p>
  
  <p>In our case, to set up a route for path: '/dashboard' component: DashboardComponent we need to declare DashboardComponent in app.module.ts, and that's fine, but since we're still in the module app.module our CharComponent is not exposed and will not render in our DashboardComponent since it's declared in dashboard.module.ts and not app.module.ts.</p>
  
  <p>If we declare ChartComponent in app.module.ts it's working as it should but we lost the architecture for our application.</p>
  
  <p>The file structure for the application is something like this:</p>
  
  <pre><code>└─ src/
     └─ app/
        ├─ app.module.ts
        ├─ app.component.ts
        ├─ app.routing.ts
        ├─ profile/
        |  ├─ profile.module.ts
        |  └─ profile.component.ts
        ├─ login/
        |  ├─ login.module.ts
        |  └─ login.component.ts
        └─ dashboard/
           ├─ dashboard.module.ts
           └─ dashboard.component.ts
              └─ chart/
                 └─ chart.component.ts
  </code></pre>