[Fixed] How to get base url in angular 5?

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);

Leave a Reply

(*) Required, Your email will not be published