title: How to determine previous page URL in Angular?
body: <p>Suppose I am currently on the page which has the URL <code>/user/:id</code> . Now from this page I navigate to next page <code>:id/posts</code>.</p>
  
  <p>Now Is there a way, so that i can check what is the previous URL, i.e. <code>/user/:id</code>.</p>
  
  <p>Below are my routes</p>
  
  <pre><code>export const routes: Routes = [
    { 
      path: 'user/:id', component: UserProfileComponent
    },
    {  
      path: ':id/posts', component: UserPostsComponet 
    }
  ];
  </code></pre>