Skip to content
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

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

Closed
MasDevProject opened this issue Oct 9, 2016 · 9 comments
Closed

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

MasDevProject opened this issue Oct 9, 2016 · 9 comments

Comments

@MasDevProject
Copy link

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
Copy link
Contributor

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

@MasDevProject
Copy link
Author

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

@DzmitryShylovich
Copy link
Contributor

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

@MasDevProject
Copy link
Author

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
Copy link
Contributor

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

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

@MasDevProject
Copy link
Author

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

@DzmitryShylovich
Copy link
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",

@tskweres
Copy link

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

@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 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants