Skip to content

CanLoad when navigate to "/" and return false. The route "/" not triggered on redirect to him #24715

@yuriystovbur

Description

@yuriystovbur

I'm submitting a...

[x] Bug report. CanLoad Guard with Route.navigate(['/'])

Previous issue: #16197

Current behavior

routes:

[
    {
        path: '',
        loadChildren: 'app/dashboard/dashboard.module#DashboardModule'
    },
    {
        path: 'test',
        loadChildren: 'app/test/test.module#TestModule',
        canLoad: [RedirectGuard]
    },
    {
        path: '**',
        redirectTo: '/'
    }
];

canLoad:

export class RedirectGuard implements CanLoad {
    constructor(private _router: Router) {}
    canLoad() {
      this._router.navigate(['/']);
      return false;
    }
}

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-4kt7bp
If I open https://angular-4kt7bp.stackblitz.io/test the route "/" not triggered on redirect to him

Environment

Angular version: 5.2.11

Browser:
- [x] Any browser

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions