title: How to get route url from another component
body: <p>I would like to access to the route url from a different component <code>(header.component.ts)</code> than the one the route belongs to.</p>
  
  <p>When I use <code>ActivatedRoute</code> or Route classes, I only see home page <code>'/'</code> and it doesn't get updated when I moved to different routes. I can only achieve this via window.location and <code>ngDoCheck()`` lifecycle</code> hook, but I would like to learn angular's own solution.</p>
  
  <p><code>header.component.ts</code></p>
  
  <pre><code>ngDoCheck() {
      console.log(window.location.pathname)
  }
  </code></pre>
  
  <p><code>app.component.ts</code></p>
  
  <pre><code>&lt;app-header&gt;&lt;/app-header&gt;
  &lt;main&gt;
    &lt;router-outlet #o="outlet"&gt;&lt;/router-outlet&gt;
  &lt;/main&gt;
  </code></pre>