The easiest way to find the current path is to either use it directly
this.router.url
or you can check the current path every time the router changes, using its events, such as
this.router.events.subscribe((res) => {
console.log(this.router.url,"Current URL");
})
where routeran instance is created here in a constructor like this
constructor(private router: Router){ ... }
source
share