When CanActivate guard redirects to / on initial load, router does not render component
See original GitHub issueI’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
When a CanActivate guard navigates to the root path /
on the initial load, the router does not render the root component. If the guard navigates elsewhere (e.g. /elsewhere
) then it correctly renders the component for that route.
Expected behavior Navigating to root should have the same behavior as navigating to any other route. It should always render.
Minimal reproduction of the problem with instructions See https://github.com/nertzy/angular-issue-13530
What is the motivation / use case for changing the behavior? This used to work in Angular 2.2.x. We want to redirect to the root path when a user is unauthenticated in our application.
-
Angular version: We’ve seen it in 2.3.1 and 2.4.1
-
Browser: all
-
Language: TypeScript
Issue Analytics
- State:
- Created 7 years ago
- Reactions:21
- Comments:35 (7 by maintainers)
Still seeing this in angular 6 as well. @grigorig did you find a workaround?
I got the same issue in Angular 4. My guard was looking like this:
Fixed it by doing this: