My current url is http://localhost:4200/test/dashboard.
I want to print base url i.e http://localhost:4200 using angular 5 features.
PlatformLocation provides more details about the URL:
import {PlatformLocation } from '@angular/common';
constructor(platformLocation: PlatformLocation) {
console.log((platformLocation as any).location);
console.log((platformLocation as any).location.href);
console.log((platformLocation as any).location.origin);
}