0

I am using Angular 13 and need help with the Activated route. In short, I have 2 x routes:

/form/:id/:settings
/report/:id/:query

Whilst I know how to fetch the params such as :id, I am having trouble working out how to determine which route the url has taken that is report or form. Meaning is there a way to fetch the constants of a url pathway like 'form' or 'report'? I really only need the parent constant.

Thanks for the help.

Ka Tech
  • 8,937
  • 14
  • 53
  • 78
  • Does this answer your question? [How to determine previous page URL in Angular?](https://stackoverflow.com/questions/41038970/how-to-determine-previous-page-url-in-angular) – Vishnudev Krishnadas Dec 19 '21 at 13:09

1 Answers1

0

You can make use of Router service to get the entire URL so you can easily check if the path contains form or report

import { Router } from '@angular/router';

constructor(private router: Router){
  console.log(this.router.url);
}
Deepak
  • 2,660
  • 2
  • 8
  • 23