title: How do I detect user navigating back in Angular2?
body: <p>I have a component and I need to detect if user pressed back button in his browser to navigate back.</p>
  
  <p>Currently I'm subscribing router events.</p>
  
  <pre><code>constructor(private router: Router, private activatedRoute: ActivatedRoute) {
  
      this.routerSubscription = router.events
          .subscribe(event =&gt; {
  
              // if (event.navigatesBack()) ...
  
          });
  
  }
  </code></pre>
  
  <p>I know that I can use <code>window.onpopstate</code> but it feels like a hack when using Angular2.</p>