title: angular2 - How do 'imports' and 'exports' work in Angular2 modules?
body: <p>I am completely new to Angular2 and it has been very difficult to understand what is going on with the <code>@NgModule</code> <strong>imports and exports in Angular2.</strong></p>
  
  <p>Take the following code for example-:</p>
  
  <pre><code>@NgModule({
    imports: [
      RouterModule.forChild(heroesRoutes)
    ],
    exports: [
      RouterModule
    ]
  })
  </code></pre>
  
  <p>In the imports section <strong>what am I importing ?</strong> <em>The router module , or the forChild() function, or the module returned by the function forChild() ?</em>
  Which one is it ?</p>
  
  <p>Also when I export the <code>RouterModule</code> again, the <a href="https://angular.io/docs/ts/latest/guide/router.html#!#routing-module" rel="noreferrer">documentation</a> says the following-:</p>
  
  <blockquote>
    <p>Our last step is to re-export the RouterModule. By re-exporting the
    RouterModule, our feature module will be provided with the Router
    Directives when using our Routing Module.</p>
  </blockquote>
  
  <p><strong>So does that mean that whatever module imports the above NgModule, will have access to all the code in the RouterModule ?</strong> </p>
  
  <p>Is it sort of like if I write a custom header file in C that includes math.h, if I now use that header file I no longer need to include math.h in my programme separately. <em>Is my analogy correct ?</em></p>
  
  <p>Can someone explain the core concepts here, so that I don't get stumped every time I see new code.</p>