The angular2 documentation about Route Guards left me unclear about when it is appropriate to use a CanActivate
guards vs. a CanActivateChild
guard
One reason I can think of is timeouts.
I'm starting to work with Angular 2, using an authentication provider. This provider expires a session which has been idle for more than a certain amount of time.
In a common situation where you leave your computer logged in and your session expires, the next navigation you try MUST validate your current situation. If you are navigating between child routes, I think CanActivateChild
is the guard that will detect the expired session, and trigger a redirect to login, while CanActivate
won't trigger at all.
Disclaimer: This came from the top of my head, I haven't implemented it yet.