Lazy load root routesHow to give correct path names for loadchildren in lazy loading angular 2 NgModule?Angular 2 Routing Does Not Work When Deployed to Http ServerLazy Load to route other than empty route in Angular 2Angular 4 ERROR Error: Uncaught (in promise): RangeError: Maximum call stack size exceededAngular 5 child route getting loaded at root Level router-outlet when using loadchildren in routingAngular4 multiple modules issuerouting navigate method not redirecting to targeted componentLazy loading don't find the declaration of my componentAngular nested routing with lazy loading issueCannot Find Match For the URL For Lazy Loaded Module

Augment Export function to support custom number formatting

bash vs. zsh: What are the practical differences?

What is the Leave No Trace way to dispose of coffee grounds?

Oil draining out shortly after turbo hose detached/broke

How to get depth and other lengths of a font?

Convert only certain words to lowercase

As easy as Three, Two, One... How fast can you go from Five to Four?

Are the guests in Westworld forbidden to tell the hosts that they are robots?

Should I put programming books I wrote a few years ago on my resume?

Generate certain list from two lists

Tikz-cd diagram arrow passing under a node - not crossing it

Diatonic chords of a pentatonic vs blues scale?

The significance of kelvin as a unit of absolute temperature

Remove border lines of SRTM tiles rendered as hillshade

I've been given a project I can't complete, what should I do?

How (un)safe is it to ride barefoot?

Do you need to let the DM know when you are multiclassing?

How many sets of dice do I need for D&D?

How can powerful telekinesis avoid violating Newton's 3rd Law?

Converting from CMYK to RGB (to work with it), then back to CMYK

How can I remove material from this wood beam?

Is Dumbledore a human lie detector?

Three questions

Why did Intel abandon unified CPU cache?



Lazy load root routes


How to give correct path names for loadchildren in lazy loading angular 2 NgModule?Angular 2 Routing Does Not Work When Deployed to Http ServerLazy Load to route other than empty route in Angular 2Angular 4 ERROR Error: Uncaught (in promise): RangeError: Maximum call stack size exceededAngular 5 child route getting loaded at root Level router-outlet when using loadchildren in routingAngular4 multiple modules issuerouting navigate method not redirecting to targeted componentLazy loading don't find the declaration of my componentAngular nested routing with lazy loading issueCannot Find Match For the URL For Lazy Loaded Module






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to build an angular app with lazy loaded modules with multiple pages:



src/app
|--app.component.ts
|--app-routing.module.ts
|--app.module.ts
|--app.component.html
|--LazyModuleA
| |--LazyModuleA.module.ts
| |--LazyModuleA-routing.module.ts
| |--LazyPageA.component.ts
| |--LazyPageA.component.html
|--LazyModuleB
|--LazyModuleB.module.ts
|--LazyModuleB-routing.module.ts
|--LazyModuleB.component.ts
|--LazyModuleB.component.html
|--LazyPageB
| |--LazyPageB.component.ts
| |--LazyPageB.component.html
|--LazyPageC
|--LazyPageC.component.ts
|--LazyPageC.component.html


The LazyPageBComponent and LazyPageCComponent should both be using the LazyModuleBComponent as outlet. However the routes should all be top level like this:



/LazyPageA (AppComponent->LazyPageAComponent)
/LazyPageB (AppComponent->LazyModuleBComponent->LazyPageBComponent)
/LazyPageC (AppComponent->LazyModuleBComponent->LazyPageCComponent)


instead of:



/LazyPageA
/LazyModuleB/LazyPageB
/LazyModuleB/LazyPageC


Therefore I use named router outlets in AppComponent and LazyModuleBComponent that should nest when navigating to LazyModuleB:



app-routing.module
''''''''''''''''''
const routes: Routes = [
path: 'LazyPageA', loadChildren: './LazyModuleA/LazyModuleA.module#LazyModuleA',
path: '**', loadChildren: './LazyModuleB/LazyModuleB.module#LazyModuleB'];
@NgModule(imports: [RouterModule.forRoot(routes)], exports: [RouterModule])
export class AppRoutingModule

app.component
'''''''''''''
<app-root><router-outlet name="app-outlet"></router-outlet></app-root>

LazyModuleA-routing.module
''''''''''''''''''''''''''
const routes: Routes = [
path: '', component: LazyPageAComponent, outlet: 'app-outlet'];
@NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
export class LazyModuleARoutingModule


Up to this point everything works as expected - /LazyPageA returns the LazyPageAComponent.



LazyModuleB.component
'''''''''''''''''''''
<p>Placeholder for a sidebar added later</p>
<router-outlet name="LazyModuleB-outlet"></router-outlet>

LazyModuleB-routing.module
''''''''''''''''''''''''''
const routes: Routes = [
path: 'LazyPageB', component: LazyPageBComponent, outlet: 'LazyModuleB-outlet',
path: 'LazyPageC', component: LazyPageCComponent, outlet: 'LazyModuleB-outlet',
path: '', pathMatch: 'full', component: LazyModuleBComponent, outlet: 'app-outlet',
path: '**', component: LazyModuleBComponent, outlet: 'app-outlet'];
@NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
export class LazyModuleBRoutingModule


By inspecting /LazyPageB I can see, that the named router outlets get nested as expected, however no component is placed in the LazyModuleB-outlet.



Therefore I suspect the mistake in the LazyModuleB-routing.module routes, however I can not find any way to make the routing in LazyModuleB work.



It would be possible to define /LazyPageB and /LazyPageC in the app-routing.module and conditionally display the components in the LazyModuleBComponent using *ngIf and the active route from Router, but obviously nested router outlets are supposed to do something like this.




Edit: By now I have doubts that this is not possible at all and I should probably rethink my project structure. If root routes have to lead to a unique component then I could ditch the lazy loading at all or reorder the compontents to modules that rely on shared modules instead.










share|improve this question






























    0















    I am trying to build an angular app with lazy loaded modules with multiple pages:



    src/app
    |--app.component.ts
    |--app-routing.module.ts
    |--app.module.ts
    |--app.component.html
    |--LazyModuleA
    | |--LazyModuleA.module.ts
    | |--LazyModuleA-routing.module.ts
    | |--LazyPageA.component.ts
    | |--LazyPageA.component.html
    |--LazyModuleB
    |--LazyModuleB.module.ts
    |--LazyModuleB-routing.module.ts
    |--LazyModuleB.component.ts
    |--LazyModuleB.component.html
    |--LazyPageB
    | |--LazyPageB.component.ts
    | |--LazyPageB.component.html
    |--LazyPageC
    |--LazyPageC.component.ts
    |--LazyPageC.component.html


    The LazyPageBComponent and LazyPageCComponent should both be using the LazyModuleBComponent as outlet. However the routes should all be top level like this:



    /LazyPageA (AppComponent->LazyPageAComponent)
    /LazyPageB (AppComponent->LazyModuleBComponent->LazyPageBComponent)
    /LazyPageC (AppComponent->LazyModuleBComponent->LazyPageCComponent)


    instead of:



    /LazyPageA
    /LazyModuleB/LazyPageB
    /LazyModuleB/LazyPageC


    Therefore I use named router outlets in AppComponent and LazyModuleBComponent that should nest when navigating to LazyModuleB:



    app-routing.module
    ''''''''''''''''''
    const routes: Routes = [
    path: 'LazyPageA', loadChildren: './LazyModuleA/LazyModuleA.module#LazyModuleA',
    path: '**', loadChildren: './LazyModuleB/LazyModuleB.module#LazyModuleB'];
    @NgModule(imports: [RouterModule.forRoot(routes)], exports: [RouterModule])
    export class AppRoutingModule

    app.component
    '''''''''''''
    <app-root><router-outlet name="app-outlet"></router-outlet></app-root>

    LazyModuleA-routing.module
    ''''''''''''''''''''''''''
    const routes: Routes = [
    path: '', component: LazyPageAComponent, outlet: 'app-outlet'];
    @NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
    export class LazyModuleARoutingModule


    Up to this point everything works as expected - /LazyPageA returns the LazyPageAComponent.



    LazyModuleB.component
    '''''''''''''''''''''
    <p>Placeholder for a sidebar added later</p>
    <router-outlet name="LazyModuleB-outlet"></router-outlet>

    LazyModuleB-routing.module
    ''''''''''''''''''''''''''
    const routes: Routes = [
    path: 'LazyPageB', component: LazyPageBComponent, outlet: 'LazyModuleB-outlet',
    path: 'LazyPageC', component: LazyPageCComponent, outlet: 'LazyModuleB-outlet',
    path: '', pathMatch: 'full', component: LazyModuleBComponent, outlet: 'app-outlet',
    path: '**', component: LazyModuleBComponent, outlet: 'app-outlet'];
    @NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
    export class LazyModuleBRoutingModule


    By inspecting /LazyPageB I can see, that the named router outlets get nested as expected, however no component is placed in the LazyModuleB-outlet.



    Therefore I suspect the mistake in the LazyModuleB-routing.module routes, however I can not find any way to make the routing in LazyModuleB work.



    It would be possible to define /LazyPageB and /LazyPageC in the app-routing.module and conditionally display the components in the LazyModuleBComponent using *ngIf and the active route from Router, but obviously nested router outlets are supposed to do something like this.




    Edit: By now I have doubts that this is not possible at all and I should probably rethink my project structure. If root routes have to lead to a unique component then I could ditch the lazy loading at all or reorder the compontents to modules that rely on shared modules instead.










    share|improve this question


























      0












      0








      0








      I am trying to build an angular app with lazy loaded modules with multiple pages:



      src/app
      |--app.component.ts
      |--app-routing.module.ts
      |--app.module.ts
      |--app.component.html
      |--LazyModuleA
      | |--LazyModuleA.module.ts
      | |--LazyModuleA-routing.module.ts
      | |--LazyPageA.component.ts
      | |--LazyPageA.component.html
      |--LazyModuleB
      |--LazyModuleB.module.ts
      |--LazyModuleB-routing.module.ts
      |--LazyModuleB.component.ts
      |--LazyModuleB.component.html
      |--LazyPageB
      | |--LazyPageB.component.ts
      | |--LazyPageB.component.html
      |--LazyPageC
      |--LazyPageC.component.ts
      |--LazyPageC.component.html


      The LazyPageBComponent and LazyPageCComponent should both be using the LazyModuleBComponent as outlet. However the routes should all be top level like this:



      /LazyPageA (AppComponent->LazyPageAComponent)
      /LazyPageB (AppComponent->LazyModuleBComponent->LazyPageBComponent)
      /LazyPageC (AppComponent->LazyModuleBComponent->LazyPageCComponent)


      instead of:



      /LazyPageA
      /LazyModuleB/LazyPageB
      /LazyModuleB/LazyPageC


      Therefore I use named router outlets in AppComponent and LazyModuleBComponent that should nest when navigating to LazyModuleB:



      app-routing.module
      ''''''''''''''''''
      const routes: Routes = [
      path: 'LazyPageA', loadChildren: './LazyModuleA/LazyModuleA.module#LazyModuleA',
      path: '**', loadChildren: './LazyModuleB/LazyModuleB.module#LazyModuleB'];
      @NgModule(imports: [RouterModule.forRoot(routes)], exports: [RouterModule])
      export class AppRoutingModule

      app.component
      '''''''''''''
      <app-root><router-outlet name="app-outlet"></router-outlet></app-root>

      LazyModuleA-routing.module
      ''''''''''''''''''''''''''
      const routes: Routes = [
      path: '', component: LazyPageAComponent, outlet: 'app-outlet'];
      @NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
      export class LazyModuleARoutingModule


      Up to this point everything works as expected - /LazyPageA returns the LazyPageAComponent.



      LazyModuleB.component
      '''''''''''''''''''''
      <p>Placeholder for a sidebar added later</p>
      <router-outlet name="LazyModuleB-outlet"></router-outlet>

      LazyModuleB-routing.module
      ''''''''''''''''''''''''''
      const routes: Routes = [
      path: 'LazyPageB', component: LazyPageBComponent, outlet: 'LazyModuleB-outlet',
      path: 'LazyPageC', component: LazyPageCComponent, outlet: 'LazyModuleB-outlet',
      path: '', pathMatch: 'full', component: LazyModuleBComponent, outlet: 'app-outlet',
      path: '**', component: LazyModuleBComponent, outlet: 'app-outlet'];
      @NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
      export class LazyModuleBRoutingModule


      By inspecting /LazyPageB I can see, that the named router outlets get nested as expected, however no component is placed in the LazyModuleB-outlet.



      Therefore I suspect the mistake in the LazyModuleB-routing.module routes, however I can not find any way to make the routing in LazyModuleB work.



      It would be possible to define /LazyPageB and /LazyPageC in the app-routing.module and conditionally display the components in the LazyModuleBComponent using *ngIf and the active route from Router, but obviously nested router outlets are supposed to do something like this.




      Edit: By now I have doubts that this is not possible at all and I should probably rethink my project structure. If root routes have to lead to a unique component then I could ditch the lazy loading at all or reorder the compontents to modules that rely on shared modules instead.










      share|improve this question
















      I am trying to build an angular app with lazy loaded modules with multiple pages:



      src/app
      |--app.component.ts
      |--app-routing.module.ts
      |--app.module.ts
      |--app.component.html
      |--LazyModuleA
      | |--LazyModuleA.module.ts
      | |--LazyModuleA-routing.module.ts
      | |--LazyPageA.component.ts
      | |--LazyPageA.component.html
      |--LazyModuleB
      |--LazyModuleB.module.ts
      |--LazyModuleB-routing.module.ts
      |--LazyModuleB.component.ts
      |--LazyModuleB.component.html
      |--LazyPageB
      | |--LazyPageB.component.ts
      | |--LazyPageB.component.html
      |--LazyPageC
      |--LazyPageC.component.ts
      |--LazyPageC.component.html


      The LazyPageBComponent and LazyPageCComponent should both be using the LazyModuleBComponent as outlet. However the routes should all be top level like this:



      /LazyPageA (AppComponent->LazyPageAComponent)
      /LazyPageB (AppComponent->LazyModuleBComponent->LazyPageBComponent)
      /LazyPageC (AppComponent->LazyModuleBComponent->LazyPageCComponent)


      instead of:



      /LazyPageA
      /LazyModuleB/LazyPageB
      /LazyModuleB/LazyPageC


      Therefore I use named router outlets in AppComponent and LazyModuleBComponent that should nest when navigating to LazyModuleB:



      app-routing.module
      ''''''''''''''''''
      const routes: Routes = [
      path: 'LazyPageA', loadChildren: './LazyModuleA/LazyModuleA.module#LazyModuleA',
      path: '**', loadChildren: './LazyModuleB/LazyModuleB.module#LazyModuleB'];
      @NgModule(imports: [RouterModule.forRoot(routes)], exports: [RouterModule])
      export class AppRoutingModule

      app.component
      '''''''''''''
      <app-root><router-outlet name="app-outlet"></router-outlet></app-root>

      LazyModuleA-routing.module
      ''''''''''''''''''''''''''
      const routes: Routes = [
      path: '', component: LazyPageAComponent, outlet: 'app-outlet'];
      @NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
      export class LazyModuleARoutingModule


      Up to this point everything works as expected - /LazyPageA returns the LazyPageAComponent.



      LazyModuleB.component
      '''''''''''''''''''''
      <p>Placeholder for a sidebar added later</p>
      <router-outlet name="LazyModuleB-outlet"></router-outlet>

      LazyModuleB-routing.module
      ''''''''''''''''''''''''''
      const routes: Routes = [
      path: 'LazyPageB', component: LazyPageBComponent, outlet: 'LazyModuleB-outlet',
      path: 'LazyPageC', component: LazyPageCComponent, outlet: 'LazyModuleB-outlet',
      path: '', pathMatch: 'full', component: LazyModuleBComponent, outlet: 'app-outlet',
      path: '**', component: LazyModuleBComponent, outlet: 'app-outlet'];
      @NgModule(imports: [RouterModule.forChild(routes)], exports: [RouterModule])
      export class LazyModuleBRoutingModule


      By inspecting /LazyPageB I can see, that the named router outlets get nested as expected, however no component is placed in the LazyModuleB-outlet.



      Therefore I suspect the mistake in the LazyModuleB-routing.module routes, however I can not find any way to make the routing in LazyModuleB work.



      It would be possible to define /LazyPageB and /LazyPageC in the app-routing.module and conditionally display the components in the LazyModuleBComponent using *ngIf and the active route from Router, but obviously nested router outlets are supposed to do something like this.




      Edit: By now I have doubts that this is not possible at all and I should probably rethink my project structure. If root routes have to lead to a unique component then I could ditch the lazy loading at all or reorder the compontents to modules that rely on shared modules instead.







      angular routing lazy-loading angular-routing angular-router






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 29 at 20:37







      Kartoffel

















      asked Mar 24 at 21:32









      KartoffelKartoffel

      115110




      115110






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328789%2flazy-load-root-routes%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328789%2flazy-load-root-routes%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현