Ensure you import the ActivatedRoute along with other necessary Router components.
import { ActivatedRoute, Params, Router, UrlSegment } from '@angular/router';
Remember to inject it into the constructor:
constructor(private route: ActivatedRoute) { ... }
Once done, you can utilize this.route
in the ngOnInit function to examine the URL. For example, you can concatenate all segments within an array using the following method as recommended by @ibgib:
let path = this.route.snapshot.url.join('/');
This will result in a string like "mars/moons/phobos".