Skip to content

Adding Lazy loaded routes results in 'import' of undefined error #1653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
drejohnson opened this issue Aug 11, 2016 · 2 comments
Closed

Adding Lazy loaded routes results in 'import' of undefined error #1653

drejohnson opened this issue Aug 11, 2016 · 2 comments

Comments

@drejohnson
Copy link

drejohnson commented Aug 11, 2016

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Ubuntu 16.04

  1. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.11-webpack.2
node: 6.3.0
os: linux x64
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.

Using the CLI trying lazy load routes like so:

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ApplicationRef } from '@angular/core';
/* App Root */
import { AppComponent } from './app.component';
/* Feature Modules */
import { HomeModule } from './home/home.module';
import { SharedModule } from './shared/shared.module';
/* App Routing */
import { routing } from './app.routing';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    HomeModule,
    routing,
    SharedModule.forRoot()
  ],
  // entryComponents: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {

}

app.routing.ts

import { Routes, RouterModule } from '@angular/router';

export const routes: Routes = [
  { path: '', redirectTo: 'about', pathMatch: 'full' },
  { path: 'about', loadChildren: './about/about.module' },
];

about.module.ts

import { NgModule } from '@angular/core';
import { CommonModule }  from '@angular/common';

import { AboutComponent } from './about.component';
import { routing } from './about.routing';

@NgModule({
  imports:      [ CommonModule, routing ],
  declarations: [ AboutComponent ],
  providers:    []
})
export class AboutModule { }
export const routing = RouterModule.forRoot(routes);

about.routing.ts

import { Routes, RouterModule }  from '@angular/router';

import { AboutComponent } from './about.component';

const routes: Routes = [
  { path: '', component: AboutComponent}
];

export const routing = RouterModule.forChild(routes);
  1. The log given by the failure. Normally this include a stack trace and some
    more information.
EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'import' of undefined
    at resolvePromise (zone.js:538)
    at zone.js:515
    at ZoneDelegate.invoke (zone.js:323)
    at Object.NgZoneImpl.inner.inner.fork.onInvoke (ng_zone_impl.js:53)
    at ZoneDelegate.invoke (zone.js:322)
    at Zone.run (zone.js:216)
    at zone.js:571
    at ZoneDelegate.invokeTask (zone.js:356)
    at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (ng_zone_impl.js:44)
    at ZoneDelegate.invokeTask (zone.js:355)
    BrowserDomAdapter.logError @  browser_adapter.js:84
    ExceptionHandler.call @ exception_handler.js:68
    ngZone.onError.subscribe.next @ application_ref.js:348
    schedulerFn @ async.js:89
    SafeSubscriber.__tryOrUnsub @ Subscriber.js:225
    SafeSubscriber.next @ Subscriber.js:174
    Subscriber._next @ Subscriber.js:124
    Subscriber.next @ Subscriber.js:88
    Subject._finalNext @ Subject.js:128
    Subject._next @ Subject.js:120
    Subject.next @ Subject.js:77
    EventEmitter.emit @ async.js:77
    NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:124
    NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:74
    ZoneDelegate.handleError @ zone.js:327
    Zone.runGuarded @ zone.js:233
    _loop_1 @ zone.js:487
    drainMicroTaskQueue @ zone.js:494
    ZoneTask.invoke @ zone.js:426
  1. Mention any other details that might be useful.

Thanks! We'll be in touch soon.

@filipesilva
Copy link
Contributor

Dupe of #1636

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants