How to use .forRoot() within feature modules hierarchy : <p>Can anyone please clarify to me how should I structure multiple nested feature modules hierarchy with .forRoot() calls?</p>

<p>For example what if I have modules like this:</p>

<pre><code>- MainModule
- SharedModule
- FeatureModuleA
    - FeatureModuleA1
    - FeatureModuleA2
- FeatureModuleB
</code></pre>

<p>All feature modules has a .forRoot() static functions. </p>

<p>How should I define <em>FeatureModuleA</em> with somehow "transfer" the .forRoot() functions?</p>

<pre><code>@NgModule({ 
  imports: [
    //- I can use .forRoot() calls here but this module not the root module
    //- I don't need to import sub-modules here, FeatureA only a wrapper
    //FeatureModuleA1.forRoot(), //WRONG!
    //FeatureModuleA2.forRoot(), //WRONG!
  ],
  exports: [
    //I cannot use .forRoot() calls here
    FeatureModuleA1, 
    FeatureModuleA2 
  ]
})
class FeatureModuleA {
  static forRoot(): ModuleWithProviders {
    return {
      //At this point I can set any other class than FeatureModuleA for root
      //So lets create a FeatureRootModuleA class: see below!
      ngModule: FeatureModuleA //should be: FeatureRootModuleA 
    };
  }
}
</code></pre>

<p>I can create another class for root usage then set it within the forRoot() function of FeatureModuleA: </p>

<pre><code>@NgModule({
  imports: [
    //Still don't need any sub module within this feature module
  ]
  exports: [
    //Still cannot use .forRoot() calls but still need to export them for root module too:
    FeatureModuleA1, 
    FeatureModuleA2 
  ]
})
class FeatureRootModuleA { }
</code></pre>

<blockquote>
  <p>But how can I "transfer" .forRoot() calls within this special
  ModuleClass?</p>
</blockquote>

<p>As I see I need to import all sub-modules directly into my root MainModule and call .forRoot() for each there:</p>

<pre><code>@NgModule({
  imports: [
    FeatureModuleA1.forRoot(),
    FeatureModuleA2.forRoot(),
    FeatureModuleA.forRoot(),
    SharedModule.forRoot()
  ]
})
class MainModule { }
</code></pre>

<p>Am I right? Before you answer please take a look at this file:
<a href="https://github.com/angular/material2/blob/master/src/lib/module.ts">https://github.com/angular/material2/blob/master/src/lib/module.ts</a></p>

<p>As I know this repo maintained by the official angular team. So they solve the above with just importing all .forRoot() calls within a special MaterialRootModule module. I don't really understand how it would be applied for my own root module? What does the <strong>root</strong> and <strong>.forRoot</strong> really means here? Is that relative to the package and not to the actual web project?</p>
