title: How can I extract the id from the url?
body: <p>The url looks like this:</p>
  
  <pre><code>http://localhost:4200/room/RECd4teOsdsro9YRcOMX/chat
  </code></pre>
  
  <p>I'm trying to extract the id part <code>(RECd4teOsdsro9YRcOMX)</code> </p>
  
  <p>I tried the following: </p>
  
  <pre><code>chatRoomUid: string;
  
  constructor(
    private route: ActivatedRoute
  ) {}
  
  ngOnInit() {
    this.chatRoom$ = this.route.parent.parent.params.pipe(
        tap(params =&gt; this.chatRoomUid = params.chatRoomUid),
        switchMap(params =&gt; {
          if (!params.chatRoomUid) return of(null);
          this.chatRoomUid = params.chatRoomUid;
        })
      );
  
      console.log(this.chatRoomUid); // returns undefined
  }
  </code></pre>
  
  <p>How can I extract the id from the url and save it to my variable <code>chatRoomUid</code>?</p>
  
  <p>Route: </p>
  
  <pre><code>{ path: 'room/:roomUid', loadChildren: () =&gt; import('@chatapp/pages/room/room.module').then(m =&gt; m.RoomModule) },
  </code></pre>
  
  <p>Edit: Added the routes</p>