I am trying to determine what the route is before it is activated so I can cache it and redirect the user back to that route after they have logged in.
In the old beta router I was able to call ComponentInstruction.routeName
in the activate hook but in the newer canActivate()
guard I do not see a way to access the intended route before it is activated.
I could store the intended route in a shared service when the user clicks on a navagtion button in my app but what about when they enter the URL in the address bar?
From angular router source files:
ActivatedRouteSnapshot
object (route) hasurl
property - array of another type, in first object in propertypath
your current path.Also inside
RouterStateSnapshot
object (state) has just string propertyurl
with current path, but with/
prefix on it.Simply pass those arguments to your canDeactivate method )