Routing issues after updating to Angular 6.1












0















The routing of my application worked as intended before I updated Angular from 4.1 to 6.1, but now I can't make sense of what I'm doing wrong.
When I navigate to root route '/' it somehow matches with my '/users' route and does not include my LayoutComponent that is my master detail component.



Here's my routers:



app-routing.module.ts





const routes: Routes = [
{
path: 'auth',
component: AuthorizeComponent
},
{
path: '',
component: LayoutComponent,
canActivate: [AuthGuard],
children: [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'home',
component: HomeComponent
},
{
path: 'tickets/ticket',
loadChildren: 'app/ticket/ticket.module#TicketModule',
},
{
path: 'tickets/department',
loadChildren: 'app/ticket-department/ticket-department.module#TicketDepartmentModule'
},
{
path: 'tickets/category',
loadChildren: 'app/ticket-category/ticket-category.module#TicketCategoryModule'
},
{
path: 'users',
loadChildren: 'app/user/user.module#UserModule'
},
{
path: 'stores',
loadChildren: 'app/store/store.module#StoreModule'
},
],
},
{
path: 'set-password',
component: SetPasswordParentComponent
},
{
path: 'error-pages',
component: ErrorPageComponent
},
{
path: '**',
component: ErrorPageComponent
}
];

@NgModule({
imports: [
RouterModule.forRoot(routes)
],
exports: [RouterModule]
})


ticket.routing.ts



const routes: Routes = [
{
path: '',
component: TicketComponent,
children: [
{
path: '',
component: TicketListComponent,
resolve: { tickets: TicketListResolver }
},
{
path: 'add',
component: AddTicketComponent
},
{
path: ':ticketId/edit',
component: EditTicketComponent,
resolve: { ticket: TicketEditResolver }
},
{
path: ':ticketId/details',
component: TicketDetailsComponent,
resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
}
]
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [RouterModule]
})


ticket-department.routing.ts



const routes: Routes = [
{
path: '',
component: TicketDepartmentComponent,
children: [
{
path: '',
component: TicketDepartmentListComponent,
resolve: { departments: TicketDepartmentListResolver }
},
{
path: 'add',
component: AddTicketDepartmentComponent
},
{
path: ':departmentId/edit',
component: EditTicketDepartmentComponent,
resolve: { department: EditTicketDepartmentResolver }
}
]
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})


ticket-category.routing.ts



const routes: Routes = [
{
path: '',
component: TicketCategoryComponent,
children: [
{
path: '',
component: TicketCategoryListComponent,
resolve: { categories: TicketCategoryListResolver }
// outlet: 'ticket-category-outlet'
},
{
path: 'add',
component: AddTicketCategoryComponent,
resolve: { departments: AddTicketCategoryResolver }
},
{
path: ':ticketCategoryId/edit',
component: EditTicketCategoryComponent,
resolve: {
category: EditTicketCategoryResolver,

}
// outlet: 'ticket-category-outlet'
}
]
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})


user.routing.ts



const routes: Routes = [
{
path: '',
component: UserComponent,
children: [
{
path: '',
component: UserListComponent,
resolve: { users: UserListResolver }
},
{
path: 'add',
component: AddUserComponent,
},
{
path: ':userId/edit',
component: EditUserComponent,
resolve: { user: EditUserResolver }
},
{
path: ':userId/details',
component: UserDetailsComponent,
}
]
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})


store.routing.ts



const routes: Routes = [
{
path: '',
component: StoreComponent,
children: [
{
path: '',
component: StoreListComponent,
resolve: { stores: StoreListResolver }
},
{
path: 'add',
component: StoreAddComponent
},

{
path: ':storeId/edit',
component: StoreEditComponent,
resolve: { store: StoreEditResolver }
}
]
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})


I'm using Augury in Chrome to view my router tree and that looks like this:



Augury Route tree



But the tree that I want looks something like this:



Expected Route tree



The root route should go to HomeComponent. I've tried removing the imports of the lazy-loaded modules in my root module, but then I get an error message saying that it can't find the components in those modules.
Any ideas as to what I'm doing wrong is greatly appreciated.










share|improve this question





























    0















    The routing of my application worked as intended before I updated Angular from 4.1 to 6.1, but now I can't make sense of what I'm doing wrong.
    When I navigate to root route '/' it somehow matches with my '/users' route and does not include my LayoutComponent that is my master detail component.



    Here's my routers:



    app-routing.module.ts





    const routes: Routes = [
    {
    path: 'auth',
    component: AuthorizeComponent
    },
    {
    path: '',
    component: LayoutComponent,
    canActivate: [AuthGuard],
    children: [
    {
    path: '',
    redirectTo: 'home',
    pathMatch: 'full'
    },
    {
    path: 'home',
    component: HomeComponent
    },
    {
    path: 'tickets/ticket',
    loadChildren: 'app/ticket/ticket.module#TicketModule',
    },
    {
    path: 'tickets/department',
    loadChildren: 'app/ticket-department/ticket-department.module#TicketDepartmentModule'
    },
    {
    path: 'tickets/category',
    loadChildren: 'app/ticket-category/ticket-category.module#TicketCategoryModule'
    },
    {
    path: 'users',
    loadChildren: 'app/user/user.module#UserModule'
    },
    {
    path: 'stores',
    loadChildren: 'app/store/store.module#StoreModule'
    },
    ],
    },
    {
    path: 'set-password',
    component: SetPasswordParentComponent
    },
    {
    path: 'error-pages',
    component: ErrorPageComponent
    },
    {
    path: '**',
    component: ErrorPageComponent
    }
    ];

    @NgModule({
    imports: [
    RouterModule.forRoot(routes)
    ],
    exports: [RouterModule]
    })


    ticket.routing.ts



    const routes: Routes = [
    {
    path: '',
    component: TicketComponent,
    children: [
    {
    path: '',
    component: TicketListComponent,
    resolve: { tickets: TicketListResolver }
    },
    {
    path: 'add',
    component: AddTicketComponent
    },
    {
    path: ':ticketId/edit',
    component: EditTicketComponent,
    resolve: { ticket: TicketEditResolver }
    },
    {
    path: ':ticketId/details',
    component: TicketDetailsComponent,
    resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
    }
    ]
    }
    ];

    @NgModule({
    imports: [
    RouterModule.forChild(routes)
    ],
    exports: [RouterModule]
    })


    ticket-department.routing.ts



    const routes: Routes = [
    {
    path: '',
    component: TicketDepartmentComponent,
    children: [
    {
    path: '',
    component: TicketDepartmentListComponent,
    resolve: { departments: TicketDepartmentListResolver }
    },
    {
    path: 'add',
    component: AddTicketDepartmentComponent
    },
    {
    path: ':departmentId/edit',
    component: EditTicketDepartmentComponent,
    resolve: { department: EditTicketDepartmentResolver }
    }
    ]
    }
    ];

    @NgModule({
    imports: [
    RouterModule.forChild(routes)
    ],
    exports: [
    RouterModule
    ]
    })


    ticket-category.routing.ts



    const routes: Routes = [
    {
    path: '',
    component: TicketCategoryComponent,
    children: [
    {
    path: '',
    component: TicketCategoryListComponent,
    resolve: { categories: TicketCategoryListResolver }
    // outlet: 'ticket-category-outlet'
    },
    {
    path: 'add',
    component: AddTicketCategoryComponent,
    resolve: { departments: AddTicketCategoryResolver }
    },
    {
    path: ':ticketCategoryId/edit',
    component: EditTicketCategoryComponent,
    resolve: {
    category: EditTicketCategoryResolver,

    }
    // outlet: 'ticket-category-outlet'
    }
    ]
    }
    ];

    @NgModule({
    imports: [
    RouterModule.forChild(routes)
    ],
    exports: [
    RouterModule
    ]
    })


    user.routing.ts



    const routes: Routes = [
    {
    path: '',
    component: UserComponent,
    children: [
    {
    path: '',
    component: UserListComponent,
    resolve: { users: UserListResolver }
    },
    {
    path: 'add',
    component: AddUserComponent,
    },
    {
    path: ':userId/edit',
    component: EditUserComponent,
    resolve: { user: EditUserResolver }
    },
    {
    path: ':userId/details',
    component: UserDetailsComponent,
    }
    ]
    }
    ];

    @NgModule({
    imports: [
    RouterModule.forChild(routes)
    ],
    exports: [
    RouterModule
    ]
    })


    store.routing.ts



    const routes: Routes = [
    {
    path: '',
    component: StoreComponent,
    children: [
    {
    path: '',
    component: StoreListComponent,
    resolve: { stores: StoreListResolver }
    },
    {
    path: 'add',
    component: StoreAddComponent
    },

    {
    path: ':storeId/edit',
    component: StoreEditComponent,
    resolve: { store: StoreEditResolver }
    }
    ]
    }
    ];

    @NgModule({
    imports: [
    RouterModule.forChild(routes)
    ],
    exports: [
    RouterModule
    ]
    })


    I'm using Augury in Chrome to view my router tree and that looks like this:



    Augury Route tree



    But the tree that I want looks something like this:



    Expected Route tree



    The root route should go to HomeComponent. I've tried removing the imports of the lazy-loaded modules in my root module, but then I get an error message saying that it can't find the components in those modules.
    Any ideas as to what I'm doing wrong is greatly appreciated.










    share|improve this question



























      0












      0








      0








      The routing of my application worked as intended before I updated Angular from 4.1 to 6.1, but now I can't make sense of what I'm doing wrong.
      When I navigate to root route '/' it somehow matches with my '/users' route and does not include my LayoutComponent that is my master detail component.



      Here's my routers:



      app-routing.module.ts





      const routes: Routes = [
      {
      path: 'auth',
      component: AuthorizeComponent
      },
      {
      path: '',
      component: LayoutComponent,
      canActivate: [AuthGuard],
      children: [
      {
      path: '',
      redirectTo: 'home',
      pathMatch: 'full'
      },
      {
      path: 'home',
      component: HomeComponent
      },
      {
      path: 'tickets/ticket',
      loadChildren: 'app/ticket/ticket.module#TicketModule',
      },
      {
      path: 'tickets/department',
      loadChildren: 'app/ticket-department/ticket-department.module#TicketDepartmentModule'
      },
      {
      path: 'tickets/category',
      loadChildren: 'app/ticket-category/ticket-category.module#TicketCategoryModule'
      },
      {
      path: 'users',
      loadChildren: 'app/user/user.module#UserModule'
      },
      {
      path: 'stores',
      loadChildren: 'app/store/store.module#StoreModule'
      },
      ],
      },
      {
      path: 'set-password',
      component: SetPasswordParentComponent
      },
      {
      path: 'error-pages',
      component: ErrorPageComponent
      },
      {
      path: '**',
      component: ErrorPageComponent
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forRoot(routes)
      ],
      exports: [RouterModule]
      })


      ticket.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: TicketComponent,
      children: [
      {
      path: '',
      component: TicketListComponent,
      resolve: { tickets: TicketListResolver }
      },
      {
      path: 'add',
      component: AddTicketComponent
      },
      {
      path: ':ticketId/edit',
      component: EditTicketComponent,
      resolve: { ticket: TicketEditResolver }
      },
      {
      path: ':ticketId/details',
      component: TicketDetailsComponent,
      resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [RouterModule]
      })


      ticket-department.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: TicketDepartmentComponent,
      children: [
      {
      path: '',
      component: TicketDepartmentListComponent,
      resolve: { departments: TicketDepartmentListResolver }
      },
      {
      path: 'add',
      component: AddTicketDepartmentComponent
      },
      {
      path: ':departmentId/edit',
      component: EditTicketDepartmentComponent,
      resolve: { department: EditTicketDepartmentResolver }
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      ticket-category.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: TicketCategoryComponent,
      children: [
      {
      path: '',
      component: TicketCategoryListComponent,
      resolve: { categories: TicketCategoryListResolver }
      // outlet: 'ticket-category-outlet'
      },
      {
      path: 'add',
      component: AddTicketCategoryComponent,
      resolve: { departments: AddTicketCategoryResolver }
      },
      {
      path: ':ticketCategoryId/edit',
      component: EditTicketCategoryComponent,
      resolve: {
      category: EditTicketCategoryResolver,

      }
      // outlet: 'ticket-category-outlet'
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      user.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: UserComponent,
      children: [
      {
      path: '',
      component: UserListComponent,
      resolve: { users: UserListResolver }
      },
      {
      path: 'add',
      component: AddUserComponent,
      },
      {
      path: ':userId/edit',
      component: EditUserComponent,
      resolve: { user: EditUserResolver }
      },
      {
      path: ':userId/details',
      component: UserDetailsComponent,
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      store.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: StoreComponent,
      children: [
      {
      path: '',
      component: StoreListComponent,
      resolve: { stores: StoreListResolver }
      },
      {
      path: 'add',
      component: StoreAddComponent
      },

      {
      path: ':storeId/edit',
      component: StoreEditComponent,
      resolve: { store: StoreEditResolver }
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      I'm using Augury in Chrome to view my router tree and that looks like this:



      Augury Route tree



      But the tree that I want looks something like this:



      Expected Route tree



      The root route should go to HomeComponent. I've tried removing the imports of the lazy-loaded modules in my root module, but then I get an error message saying that it can't find the components in those modules.
      Any ideas as to what I'm doing wrong is greatly appreciated.










      share|improve this question
















      The routing of my application worked as intended before I updated Angular from 4.1 to 6.1, but now I can't make sense of what I'm doing wrong.
      When I navigate to root route '/' it somehow matches with my '/users' route and does not include my LayoutComponent that is my master detail component.



      Here's my routers:



      app-routing.module.ts





      const routes: Routes = [
      {
      path: 'auth',
      component: AuthorizeComponent
      },
      {
      path: '',
      component: LayoutComponent,
      canActivate: [AuthGuard],
      children: [
      {
      path: '',
      redirectTo: 'home',
      pathMatch: 'full'
      },
      {
      path: 'home',
      component: HomeComponent
      },
      {
      path: 'tickets/ticket',
      loadChildren: 'app/ticket/ticket.module#TicketModule',
      },
      {
      path: 'tickets/department',
      loadChildren: 'app/ticket-department/ticket-department.module#TicketDepartmentModule'
      },
      {
      path: 'tickets/category',
      loadChildren: 'app/ticket-category/ticket-category.module#TicketCategoryModule'
      },
      {
      path: 'users',
      loadChildren: 'app/user/user.module#UserModule'
      },
      {
      path: 'stores',
      loadChildren: 'app/store/store.module#StoreModule'
      },
      ],
      },
      {
      path: 'set-password',
      component: SetPasswordParentComponent
      },
      {
      path: 'error-pages',
      component: ErrorPageComponent
      },
      {
      path: '**',
      component: ErrorPageComponent
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forRoot(routes)
      ],
      exports: [RouterModule]
      })


      ticket.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: TicketComponent,
      children: [
      {
      path: '',
      component: TicketListComponent,
      resolve: { tickets: TicketListResolver }
      },
      {
      path: 'add',
      component: AddTicketComponent
      },
      {
      path: ':ticketId/edit',
      component: EditTicketComponent,
      resolve: { ticket: TicketEditResolver }
      },
      {
      path: ':ticketId/details',
      component: TicketDetailsComponent,
      resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [RouterModule]
      })


      ticket-department.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: TicketDepartmentComponent,
      children: [
      {
      path: '',
      component: TicketDepartmentListComponent,
      resolve: { departments: TicketDepartmentListResolver }
      },
      {
      path: 'add',
      component: AddTicketDepartmentComponent
      },
      {
      path: ':departmentId/edit',
      component: EditTicketDepartmentComponent,
      resolve: { department: EditTicketDepartmentResolver }
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      ticket-category.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: TicketCategoryComponent,
      children: [
      {
      path: '',
      component: TicketCategoryListComponent,
      resolve: { categories: TicketCategoryListResolver }
      // outlet: 'ticket-category-outlet'
      },
      {
      path: 'add',
      component: AddTicketCategoryComponent,
      resolve: { departments: AddTicketCategoryResolver }
      },
      {
      path: ':ticketCategoryId/edit',
      component: EditTicketCategoryComponent,
      resolve: {
      category: EditTicketCategoryResolver,

      }
      // outlet: 'ticket-category-outlet'
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      user.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: UserComponent,
      children: [
      {
      path: '',
      component: UserListComponent,
      resolve: { users: UserListResolver }
      },
      {
      path: 'add',
      component: AddUserComponent,
      },
      {
      path: ':userId/edit',
      component: EditUserComponent,
      resolve: { user: EditUserResolver }
      },
      {
      path: ':userId/details',
      component: UserDetailsComponent,
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      store.routing.ts



      const routes: Routes = [
      {
      path: '',
      component: StoreComponent,
      children: [
      {
      path: '',
      component: StoreListComponent,
      resolve: { stores: StoreListResolver }
      },
      {
      path: 'add',
      component: StoreAddComponent
      },

      {
      path: ':storeId/edit',
      component: StoreEditComponent,
      resolve: { store: StoreEditResolver }
      }
      ]
      }
      ];

      @NgModule({
      imports: [
      RouterModule.forChild(routes)
      ],
      exports: [
      RouterModule
      ]
      })


      I'm using Augury in Chrome to view my router tree and that looks like this:



      Augury Route tree



      But the tree that I want looks something like this:



      Expected Route tree



      The root route should go to HomeComponent. I've tried removing the imports of the lazy-loaded modules in my root module, but then I get an error message saying that it can't find the components in those modules.
      Any ideas as to what I'm doing wrong is greatly appreciated.







      angular routing






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 27 '18 at 10:58









      Flix

      305111




      305111










      asked Nov 27 '18 at 9:53









      Martin JohanssonMartin Johansson

      2781615




      2781615
























          1 Answer
          1






          active

          oldest

          votes


















          0














          So, I fixed this by changing a few things:



          First I changed all loadChildren lines in app-routing.module.ts from



          loadChildren: 'app/ticket/ticket.module#TicketModule'



          to



          loadChildren: () => TicketModule



          Then, for some reason, I had to name all my root routes in my childrouting modules like this:



          const routes: Routes = [
          {
          path: 'tickets',
          component: TicketComponent,
          children: [
          {
          path: '',
          component: TicketListComponent,
          resolve: { tickets: TicketListResolver },
          pathMatch: 'full'
          },
          {
          path: 'add',
          component: AddTicketComponent
          },
          {
          path: ':ticketId/edit',
          component: EditTicketComponent,
          resolve: { ticket: TicketEditResolver }
          },
          {
          path: ':ticketId/details',
          component: TicketDetailsComponent,
          resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
          }
          ]
          }
          ];

          @NgModule({
          imports: [
          RouterModule.forChild(routes)
          ],
          exports: [
          RouterModule
          ]
          })


          Now, the routing works as intended.






          share|improve this answer























            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%2f53496949%2frouting-issues-after-updating-to-angular-6-1%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            So, I fixed this by changing a few things:



            First I changed all loadChildren lines in app-routing.module.ts from



            loadChildren: 'app/ticket/ticket.module#TicketModule'



            to



            loadChildren: () => TicketModule



            Then, for some reason, I had to name all my root routes in my childrouting modules like this:



            const routes: Routes = [
            {
            path: 'tickets',
            component: TicketComponent,
            children: [
            {
            path: '',
            component: TicketListComponent,
            resolve: { tickets: TicketListResolver },
            pathMatch: 'full'
            },
            {
            path: 'add',
            component: AddTicketComponent
            },
            {
            path: ':ticketId/edit',
            component: EditTicketComponent,
            resolve: { ticket: TicketEditResolver }
            },
            {
            path: ':ticketId/details',
            component: TicketDetailsComponent,
            resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
            }
            ]
            }
            ];

            @NgModule({
            imports: [
            RouterModule.forChild(routes)
            ],
            exports: [
            RouterModule
            ]
            })


            Now, the routing works as intended.






            share|improve this answer




























              0














              So, I fixed this by changing a few things:



              First I changed all loadChildren lines in app-routing.module.ts from



              loadChildren: 'app/ticket/ticket.module#TicketModule'



              to



              loadChildren: () => TicketModule



              Then, for some reason, I had to name all my root routes in my childrouting modules like this:



              const routes: Routes = [
              {
              path: 'tickets',
              component: TicketComponent,
              children: [
              {
              path: '',
              component: TicketListComponent,
              resolve: { tickets: TicketListResolver },
              pathMatch: 'full'
              },
              {
              path: 'add',
              component: AddTicketComponent
              },
              {
              path: ':ticketId/edit',
              component: EditTicketComponent,
              resolve: { ticket: TicketEditResolver }
              },
              {
              path: ':ticketId/details',
              component: TicketDetailsComponent,
              resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
              }
              ]
              }
              ];

              @NgModule({
              imports: [
              RouterModule.forChild(routes)
              ],
              exports: [
              RouterModule
              ]
              })


              Now, the routing works as intended.






              share|improve this answer


























                0












                0








                0







                So, I fixed this by changing a few things:



                First I changed all loadChildren lines in app-routing.module.ts from



                loadChildren: 'app/ticket/ticket.module#TicketModule'



                to



                loadChildren: () => TicketModule



                Then, for some reason, I had to name all my root routes in my childrouting modules like this:



                const routes: Routes = [
                {
                path: 'tickets',
                component: TicketComponent,
                children: [
                {
                path: '',
                component: TicketListComponent,
                resolve: { tickets: TicketListResolver },
                pathMatch: 'full'
                },
                {
                path: 'add',
                component: AddTicketComponent
                },
                {
                path: ':ticketId/edit',
                component: EditTicketComponent,
                resolve: { ticket: TicketEditResolver }
                },
                {
                path: ':ticketId/details',
                component: TicketDetailsComponent,
                resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
                }
                ]
                }
                ];

                @NgModule({
                imports: [
                RouterModule.forChild(routes)
                ],
                exports: [
                RouterModule
                ]
                })


                Now, the routing works as intended.






                share|improve this answer













                So, I fixed this by changing a few things:



                First I changed all loadChildren lines in app-routing.module.ts from



                loadChildren: 'app/ticket/ticket.module#TicketModule'



                to



                loadChildren: () => TicketModule



                Then, for some reason, I had to name all my root routes in my childrouting modules like this:



                const routes: Routes = [
                {
                path: 'tickets',
                component: TicketComponent,
                children: [
                {
                path: '',
                component: TicketListComponent,
                resolve: { tickets: TicketListResolver },
                pathMatch: 'full'
                },
                {
                path: 'add',
                component: AddTicketComponent
                },
                {
                path: ':ticketId/edit',
                component: EditTicketComponent,
                resolve: { ticket: TicketEditResolver }
                },
                {
                path: ':ticketId/details',
                component: TicketDetailsComponent,
                resolve: { ticket: TicketDetailsResolver, user: TicketDetailsUserResolver }
                }
                ]
                }
                ];

                @NgModule({
                imports: [
                RouterModule.forChild(routes)
                ],
                exports: [
                RouterModule
                ]
                })


                Now, the routing works as intended.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 28 '18 at 9:42









                Martin JohanssonMartin Johansson

                2781615




                2781615
































                    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%2f53496949%2frouting-issues-after-updating-to-angular-6-1%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

                    Lallio

                    Unable to find Lightning Node

                    Futebolista