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"
Share:
23,328
Suvonkar
Author by

Suvonkar

Updated on July 05, 2022

Comments