How to get base url in angular 5?

him picture him · Aug 23, 2018 · Viewed 51k times · Source

My current url is http://localhost:4200/test/dashboard.

I want to print base url i.e http://localhost:4200 using angular 5 features.

Answer

bugs picture bugs · Aug 23, 2018

No need for angular specific features, window.location.origin will do it for you.