title: get current route component instance or guards
body: <p>I have the navigation area including a logout button next to my router-outlet.</p>
  
  <p><em>app.component.html:</em></p>
  
  <pre><code>&lt;my-nav-header&gt;&lt;/my-nav-header&gt;
  &lt;router-outlet&gt;&lt;/router-outlet&gt;
  </code></pre>
  
  <p>On every module/component in the router I have implemented a canDeactivate method for dirty-checking (as described in the Routing &amp; Naviagtion tutorial of angular) that is called from the actual canDeactivateGuard via an interface as described in that tutorial. This works as expected - when a user clicks a router link and has unsaved changes he is asked whether to route anyway or not.</p>
  
  <p><em>my-nav-header.component.ts</em></p>
  
  <pre><code>logoutBtnClick(){
      // todo: insert call to canDeactivate here
      // or find another way to get dirty state of current component in router
      //console.debug('logout - can deactivate[1]: ', this.activatedRoute.routeConfig.canDeactivate);
      //console.debug('logout - can deactivate[2]: ', this.activatedRoute.snapshot.routeConfig.canDeactivate);
      this.loginSvc.doLogout();
  }
  </code></pre>
  
  <p><em>login.service.ts</em></p>
  
  <pre><code>@Injectable()
  export class LoginService {
  
  ...
  
    public doLogout(){
      this.myHttp.sendLogout().subscribe(
          ()=&gt; {
              this.clearSessionData();
              this.myHttp.clearSessionData();
              this.router.navigate(['/login']); // triggering canDeactivate, but too late as logout command already has been sent to the server
    }
  </code></pre>
  
  <p>When the user presses the logout button I want the dirty check to be executed (giving the user the possibility to cancel logout) before my logout method actually sends the logout command to the server.</p>
  
  <p>I have tried to inject both <code>Router</code> and <code>ActivatedRoute</code> into my navigation header component, but in both cases the rootConfig property is null preventing me from accessing canDeactivate.</p>
  
  <p>So my question is: How to access either the canDeactivate guard of the current route or the instance of the current route component itself?</p>