title: How to get target route in ng2 guard canActivate?
body: <p>How can I get the route which the user is trying to open within an canActivate guard in angular 2?</p>
  
  <p>How can I make the guard watch for every route parameter change eg. a change of the id within the route?</p>
  
  <pre><code>import { Injectable }       from '@angular/core';
  import {Observable, Observer, Subject} from "rxjs/Rx";
  
  @Injectable()
  export class RightsGuard implements CanActivate {
      constructor(
        private router: Router,
        private route: ActivatedRoute
        // private state: RouterStateSnapshot
      ) { }
  
      canActivate(): Observable&lt;boolean&gt; | boolean {
        var targetUrl = ???
        // var targetUrl = this.router.url // is showing previous url?
        return true;
      }
  }
  </code></pre>
  
  <p>Suggested answer in <a href="https://stackoverflow.com/questions/39747246/angular-2-get-current-route-in-guard">Angular 2 get current route in guard</a> using <code>private state: RouterStateSnapshot</code>
    and then <code>this.route.url</code> does not work for me, since it throws an DI error: </p>
  
  <pre><code>Error: Uncaught (in promise): Error: DI Error
  Error: DI Error
  </code></pre>