Get group lookup value (**)
Is there a way to get (and display) the current route (**) for the user?
So, for example, one could display its value like this:
Sorry, but the page "/ WrongUrl" does not exist
Edit
To be clear, this question is about displaying a URL for UI purposes. Not how to create the correct route for a 404 error.
source to share
The current route is available as a property url
in Router
and ActivatedRoute
.
This is in line Router
, events
observable must be signed in order to keep track of the change:
router.events
.filter(e => e instanceof NavigationEnd)
.subscribe(({ url }) => {
this.currentUrl = url;
});
This is an observation of parsed URL segments in ActivatedRoute
, it should be serialized to a string:
activatedRoute.url
.subscribe(urlSegments => {
this.currentUrl = '/' + urlSegments.join('/');
});
source to share