Issue
My current url is http://localhost:4200/test/dashboard.
I want to print base url i.e http://localhost:4200 using angular 5 features.
Solution
console.log(location);
console.log(location.href);
to get base url : console.log(location.origin);