title: How to get current route's module in Angular
body: <p>I'm working on a simple component that would change data based on the current route's module. I'm not sure where to find the information about that module.</p>
  
  <p>Router</p>
  
  <pre class="lang-js prettyprint-override"><code>const routes: Routes = [
      {
          path: '', 
          loadChildren: () =&gt; import('@/app/homepage/homepage.module').then(m =&gt; m.HomepageModule)
      },
      {
          path: 'search', 
          loadChildren: () =&gt; import('@/app/search/search.module').then(m =&gt; m.SearchModule)
      }
  ];
  </code></pre>
  
  <p>AppComponent (root)</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div *ngIf="isHomepageModule; else otherModules"&gt;...&lt;/div&gt;
  &lt;ng-template #otherModules&gt;
      &lt;div&gt;...&lt;/div&gt;
  &lt;/ng-template&gt;
  &lt;router-outlet&gt;&lt;/router-outlet&gt;
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>constructor(private route: ActivatedRoute) {}
  
  get isHomepageModule() {
      // This would be the ideal situation... 
      // Unfortunately, I cannot find any information about the module here
      return this.route.snapshot.module instanceof HomepageModule;
  }
  </code></pre>
  
  <p>Is the module information even accessible? I would prefer doing the type checking or module name comparison than just "brute-forcing" the check with some regex matching of the current url. Thank you in advance.</p>