title: this.router.events not loading on first time in Angular
body: <p>Does anyone have any idea on how to get the router events to fire the first time the component is loaded?</p>
  
  <p>I am using Angular 8.</p>
  
  <p>I have a deep link that moves to another component. So when I click on the deep link its redirect to the Home page. This happens whenever the computer starts a new session. </p>
  
  <p>So as per my investigation when the app loads for the first time it (this.router.events) returns nothing.</p>
  
  <p>Can anyone please suggest to me regarding it.</p>
  
  <p>Following is my code:-
  app.component.ts</p>
  
  <pre><code> ngAfterViewInit() {
      this.getActivatedRoute();
  }
  </code></pre>
  
  <pre><code>getActivatedRoute() {
      debugger
      const routerSub$ = this.router.events.subscribe((event) =&gt; {
        if (event instanceof NavigationEnd) {
          this.routes = event.url.toLowerCase().split('/');
          this.currentRoute = this.routes[1];
          if (this.currentRoute !== this.previousRoute) {
            this.setBodyClassBasedOnRouter(this.routes);
            this.previousRoute = this.currentRoute;
          }
        }
      });
    }
  </code></pre>