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
No provider error when attempting to use _ActivatedRouteSnapshot_ in a guard applied to initially loaded URL (_CanActivate_ function called during initial page load). _Router_ object is accessible but state snapshot url property is an empty string.
Expected behavior
No error, URL/route information available regardless of when _CanActivate_ is called.
Reproduction of the problem
http://plnkr.co/edit/aJpxcpvperSM0qzcvd4G
Define a route in main app module with a _CanActivate_ guard service with _ActivatedRouteSnapshot_ in constructor and try to load that route initially. Workaround: subscribe to router events in main app constructor and save initial URL; reference this string in the _CanActivate_ if current router state snapshot url is blank.
What is the motivation / use case for changing the behavior?
Apply route guard to initial URL
Please tell us about your environment:
SystemJS loader
node --version = The ActivatedRouteSnapshot and RouterStateSnapshot are not injected. They are arguments in the canActivate method.
You can use the RouterStateSnapshot.url to get the intended destination URL
@brandonroberts
Geez, don't know how I messed this up, thanks for pointing me in the right direction!
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._
Most helpful comment
The
ActivatedRouteSnapshotandRouterStateSnapshotare not injected. They are arguments in thecanActivatemethod.You can use the
RouterStateSnapshot.urlto get the intended destination URLhttp://plnkr.co/edit/Wj0mRchDCUxGAdipPsuW?p=preview