question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lazy loaded module in named outlet throws error

See original GitHub issue

[x] bug report [ ] feature request [ ] support request

Current behavior Navigating to route with lazy loaded module in named outlet throws error:

Uncaught (in promise): TypeError: Cannot read property ‘routes’ of undefined

Expected behavior Navigating to route with lazy loaded module in named outlet without errors.

Minimal reproduction of the problem with instructions When I have configured my routes with named outlet and want to have lazy loaded module in that outlet.

export const routes: Routes = [
 {  
   path: '',
   component: AppComponent,
   children: [
     {
       path: '',
       loadChildren: "app/home/home.module#HomeModule"
     },   {
       path: '',
       loadChildren: "app/about/about.module#AboutModule",
       outlet: "about"
     }
   ]
  }
];

Here is the plnkr to demonstrate the behavior: http://plnkr.co/edit/nK9kJYdakXILZU0UKFrP?p=preview (Anything is displayed because of error)

What is the motivation / use case for changing the behavior? Using lazy loaded modules in named outlets.

Please tell us about your environment:

Angular version: 2.0.X

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Language: [all | TypeScript X.X | ES6/7 | ES5]

Node (for AoT issues): node --version =

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:120
  • Comments:58 (12 by maintainers)

github_iconTop GitHub Comments

53reactions
jamesbirtlescommented, Jan 6, 2017

We have this

    {
        path: 'me',
        outlet: 'hub',
        component: ProxyRouteComponent,
        children: [
            {
                path: '',
                loadChildren: 'hub#HubModule',
            },
        ],
    },

Where proxy route component is simply

import { Component } from '@angular/core';

@Component({
    selector: 'b-proxy-route',
    template: '<router-outlet></router-outlet>',
})
export class ProxyRouteComponent {
}
26reactions
wosevisioncommented, Oct 26, 2017

Though I don’t want to speak on behalf of the Angular team, I feel like something needs to be said here:

This issue doesn’t get closer to resolution in proportion to the number of comments that say “Any update on this”/“Any fix for this”/etc. Thumbs-upping those comments doesn’t magically go into some petition for the Angular team to finish this.

If you’re stuck, read the thread – there’s a workaround, which as the name suggests, will get you working. If you’d like to get updates on this, save some keystrokes by clicking the ‘Subscribe’ button – that allows you to receive updates in your email. You’ll also receive updates every time someone comments “Any update on this?”, so please, don’t be that person.

Better yet, be the change you want to see in the world and submit a pull request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular lazy load with named outlet not working
When module is lazy load then parent component's path needs to be set as empty. This is the issue here, the child component...
Read more >
Lazy-loading feature modules - Angular
A common error when lazy-loading modules is importing common modules in multiple places within an application. Test for this condition by first generating...
Read more >
Angular Router: Child Routes, Auxiliary Routes, Master Detail
This is a comprehensive guide to the fundamental concepts of the Angular Router: routes, paths, components, outlets.
Read more >
Lazy loaded module in named outlet throws error-angular.js
[Solved]-Lazy loaded module in named outlet throws error-angular.js ... Its fixed in angular 11 and changelog of angular 11 confirms that. please find...
Read more >
Named Router Outlets in Angular (Auxiliary Routes ... - Medium
Lazy -Loading Router-Outlets: Named Router Outlets in Angular (Auxiliary Routes) · The load time of the modules can be reduced. · If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found