Exception using dynamic module in wildcard route (**) #12183

Closed
MasDevProject opened this Issue Oct 9, 2016 · 8 comments

Comments

Projects
None yet
5 participants
@MasDevProject

MasDevProject commented Oct 9, 2016

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
If I try to load a dynamic Module as wildcard, I get a null pointer exception:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';

@NgModule({
    imports: [
        BrowserModule,
        RouterModule.forRoot([
                        { path: '', redirectTo: 'login', pathMatch: 'full' },
            { path: 'login', loadChildren: 'app/login/login.module#LoginModule' },
            { path: 'not-found', loadChildren: 'app/not-found/not-found.module#NotFoundModule' },
            { path: '**', redirectTo: 'not-found', pathMatch: 'full' }
        ])
    ],
    declarations: [
        AppComponent
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

This is the error I get:
handleError — core.umd.js:3370EXCEPTION: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'route._loadedConfig.routes')

Minimal reproduction of the problem with instructions
Here you can find a ready project

  • Angular version: 2.0.1
  • Browser: [all]
  • Language: [all]
  • Node (for AoT issues): node --version = 6.6
@DzmitryShylovich

This comment has been minimized.

Show comment
Hide comment
@DzmitryShylovich

DzmitryShylovich Oct 9, 2016

Contributor

Thanks for reporting this issue. Luckily it has already been fixed #12024

Contributor

DzmitryShylovich commented Oct 9, 2016

Thanks for reporting this issue. Luckily it has already been fixed #12024

@MasDevProject

This comment has been minimized.

Show comment
Hide comment
@MasDevProject

MasDevProject Oct 9, 2016

Thank you @DzmitryShylovich!
I will check it again when you will release v2.0.3

Thank you @DzmitryShylovich!
I will check it again when you will release v2.0.3

@DzmitryShylovich

This comment has been minimized.

Show comment
Hide comment
@DzmitryShylovich

DzmitryShylovich Oct 9, 2016

Contributor

try "@angular/router": "3.1.0-rc.0",

Contributor

DzmitryShylovich commented Oct 9, 2016

try "@angular/router": "3.1.0-rc.0",

@MasDevProject

This comment has been minimized.

Show comment
Hide comment
@MasDevProject

MasDevProject Oct 9, 2016

Just tried with:

        "@angular/common": "2.1.0-rc.0"
        "@angular/compiler": "~2.0.2",
        "@angular/core": "2.1.0-rc.0",
        "@angular/forms": "~2.0.2",
        "@angular/http": "~2.0.2",
        "@angular/platform-browser": "2.1.0-rc.0",
        "@angular/platform-browser-dynamic": "~2.0.2",
        "@angular/router": "3.1.0-rc.0",

But unfortunately the problem persists

MasDevProject commented Oct 9, 2016

Just tried with:

        "@angular/common": "2.1.0-rc.0"
        "@angular/compiler": "~2.0.2",
        "@angular/core": "2.1.0-rc.0",
        "@angular/forms": "~2.0.2",
        "@angular/http": "~2.0.2",
        "@angular/platform-browser": "2.1.0-rc.0",
        "@angular/platform-browser-dynamic": "~2.0.2",
        "@angular/router": "3.1.0-rc.0",

But unfortunately the problem persists

@DzmitryShylovich

This comment has been minimized.

Show comment
Hide comment
@DzmitryShylovich

DzmitryShylovich Oct 9, 2016

Contributor

so it's not released yet.
You have 2 options:

  1. "@angular/router": "github:angular/router-builds",
  2. wait for the next release.
Contributor

DzmitryShylovich commented Oct 9, 2016

so it's not released yet.
You have 2 options:

  1. "@angular/router": "github:angular/router-builds",
  2. wait for the next release.
@MasDevProject

This comment has been minimized.

Show comment
Hide comment
@MasDevProject

MasDevProject Oct 9, 2016

I tried with the first solution but the problem remains.
maybe this is a different problem

I tried with the first solution but the problem remains.
maybe this is a different problem

@DzmitryShylovich

This comment has been minimized.

Show comment
Hide comment
@DzmitryShylovich

DzmitryShylovich Oct 9, 2016

Contributor

@pkozlowski-opensource
I can confirm. This is still an issue with the latest router.
Error: http://prntscr.com/crr34m
Config:

export const routes: Routes = [
  { path: '', component: DashboardComponent, pathMatch: 'full' },
  { path: 'lazy', loadChildren: './features/lazy/index#LazyModule' },
  { path: 'sync', loadChildren: './features/sync/index#SyncModule?sync=true' },
  { path: '**', redirectTo: 'lazy' }
];

Also I can reproduce #12024 . Works fine when navigating using routerLink but fails when entering url directly into browser url bar.
Error: http://prnt.sc/crr27k
Config:

export const routes: Routes = [
  { path: '', component: DashboardComponent, pathMatch: 'full' },
  { path: 'sync', loadChildren: './features/sync/index#SyncModule?sync=true' },
  { path: '**', loadChildren: './features/lazy/index#LazyModule' }
];

Router version: "@angular/router": "github:angular/router-builds",

Contributor

DzmitryShylovich commented Oct 9, 2016

@pkozlowski-opensource
I can confirm. This is still an issue with the latest router.
Error: http://prntscr.com/crr34m
Config:

export const routes: Routes = [
  { path: '', component: DashboardComponent, pathMatch: 'full' },
  { path: 'lazy', loadChildren: './features/lazy/index#LazyModule' },
  { path: 'sync', loadChildren: './features/sync/index#SyncModule?sync=true' },
  { path: '**', redirectTo: 'lazy' }
];

Also I can reproduce #12024 . Works fine when navigating using routerLink but fails when entering url directly into browser url bar.
Error: http://prnt.sc/crr27k
Config:

export const routes: Routes = [
  { path: '', component: DashboardComponent, pathMatch: 'full' },
  { path: 'sync', loadChildren: './features/sync/index#SyncModule?sync=true' },
  { path: '**', loadChildren: './features/lazy/index#LazyModule' }
];

Router version: "@angular/router": "github:angular/router-builds",

vsavkin added a commit to vsavkin/angular that referenced this issue Oct 12, 2016

vsavkin added a commit to vsavkin/angular that referenced this issue Oct 19, 2016

@alxhub alxhub closed this in 5ae6915 Oct 20, 2016

btrigueiro added a commit to btrigueiro/angular that referenced this issue Oct 21, 2016

@tskweres

This comment has been minimized.

Show comment
Hide comment
@tskweres

tskweres May 15, 2017

I am still unable to lazyload wildcard "**" routes in Angular 4.x, is this fixed somewhere?

I am still unable to lazyload wildcard "**" routes in Angular 4.x, is this fixed somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment