How to get current route in canActive route?

angular, angular2-routing, webpack

Solution

Using `route: ActivatedRouteSnapshot` can solve you problem:

canActivate(route: ActivatedRouteSnapshot) {
      console.log(route.url);

      ...
}

You can see full spec here for the `ActivatedRouteSnapshot` object:

Problem

I want to restrict route as per role. I want to check whether navigated route does have permission to access page or not in my canActivate method. But, `this.router.url` this giving me previous route instead of current navigated route.

Original source