-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
What is the current behavior?
When trying to make navigation by pasting the URL in the browser (not by any angular routing methods) canLoad function, ngrx/router-store throws an error:
TypeError: null is not an object (evaluating 'this.storeState['routerReducer'].state.url') navigateIfNeeded
Here is the repo to reproduce the issue: https://github.com/MikeSaprykin/ngrx-router-store-canLoad-bug ---> start the app, and navigate in browser by pasting localhost:4200/dashboard in the search bar.
Expected behavior:
All good, lazy-loading route not loaded, redirected to an appropriate route
Minimal reproduction of the problem with instructions:
Here are some files to reproduce:
app.routing.ts
export const APP_ROUTES: Routes = [
{
path: '',
redirectTo: 'login',
pathMatch: 'full',
},
{
path: 'login',
loadChildren: './pages/login/login.module#LoginModule',
canActivate: [
LoginGuard
]
},
{
path: 'dashboard',
loadChildren: './pages/dashboard/dashboard.module#DashboardModule',
canLoad: [
DashboardGuard
]
}
];DashboardGuard file:
@Injectable()
export class DashboardGuard implements CanLoad {
constructor(public router: Router) {}
canLoad(route): Observable<boolean> | Promise<boolean> | boolean {
this.router.navigate(['/login']);
return false;
}
}Version of affected browser(s),operating system(s), npm, node and ngrx:
angular/cli: 1.2.4
npm: 5.3.0
node: 8.0.0
os: darwin x64
ngrx/effects: ^4.0.1,
ngrx/router-store": ^4.0.0,
ngrx/store: ^4.0.0,
ngrx/store-devtools: ^4.0.0,
Other information:
Reactions are currently unavailable