title: Angular 9 how to get the previous route path
body: <p>I need your assistance to get the previous route path. I am using the below link to get that but it doesn't trigger at first time...</p>
  <p><a href="https://stackoverflow.com/questions/41038970/how-to-determine-previous-page-url-in-angular">How to determine previous page URL in Angular?</a></p>
  <pre><code>constructor(router: Router) {
    router.events
    .pipe(filter(event =&gt; event instanceof NavigationEnd))
    .subscribe((event: NavigationEnd) =&gt; {
      console.log('prev:', event.previousUrl);
      this.previousUrl = event.url;
    });
  }
  </code></pre>
  <p>I used both RoutesRecognized and NavigationEnd but didn't get that..</p>
  <p>I called this method in constructor and ngOnInit but every time it doesn't trigger at first time....</p>
  <p>is there any way, I can get that...</p>
  <p>Thanks...</p>