Get base url in AngularJS
Try this: $location.$$absUrl
console.log('$location',$location.$$absUrl);
btw /localhost
is your base path, but I guess you meant entire URL.
An alternative answer is using the $window
service in conjunction with $location.absUrl()
to create a new URL object, and then grab the origin via the origin property. This will give you exactly what you're looking for (minus the trailing '/').
$scope.baseUrl = new $window.URL($location.absUrl()).origin;
will give you back http://localhost:9000 in your case.
To get just the baseurl and nothing else use
$browser.baseHref()
it will return something like
/central/