Angular 5: Get host name and app name from URL
23,328
window.location contains lots of information. Suppose the URL is https://example.com:80/a/b/c, you can get following information easily in Angular:
window.location.hostname = "example.com"
window.location.host = "example.com:80"
window.location.protocol = "https:"
window.location.port = "80"
window.location.pathname = "/a/b/c"
window.location.href = "https://example.com:80/a/b/c"
Author by
Suvonkar
Updated on July 05, 2022Comments
-
Suvonkar almost 2 years
My current url is:
https://localhost:8080/MyApp/manager/dashboard
Within the above url I want to fetch only https://localhost:8080/MyApp/ part.
Is there any way to fetch this without hard coding anything?