I am in the process of developing a web application using Angular2 (v. 2.1.1) for the frontend.
Is there a way to extract the base URL, without any parameters, as a string?
If my current URL is foo/bar/1/2/3
, I am looking for a method to retrieve just foo/bar
. It's important to note that the URL may vary and should also work with URLs like /another/url/1/2
.
I have attempted to use the ActivatedRoute.url
, which only gives me ['bar', '1', '2', '3']
, missing the initial part (foo/
) for some reason.
I have also experimented with the Location.url
, but that returns the complete URL.
Any assistance on this matter would be greatly appreciated.