Is there a way to get the initial route's url(the route that happens when you reload the page).
I want to apply a css style to an element based on it.
So far I injected ActivatedRoute console logged it like so:
constructor(private router: Router, private actRoute: ActivatedRouteSnapshot) {
console.log(actRoute);
Chrome then shows an ActivatedRoute object containing a _routerState property which has a snapshot with the url that I want.
The problem is that when I do: console.log(actRoute._routerState);
I get an error because the router state property doesn't exist.
Am I missing something here? Because just writing actRoute.url
or actRoute.snapshot.url
just gives an empty path.
Thanks.
My imports:
import { Router, ActivatedRoute } from '@angular/router';