Skip to content
Advertisement

Get base url in AngularJS

I want to get the base path of my Angular app.

Right now I’m doing this: $scope.baseUrl = '$location.host()

But I only get this: /localhost. My current baseURL is http://localhost:9000/.

Advertisement

Answer

Try this: $location.$$absUrl

console.log('$location',$location.$$absUrl);

btw /localhost is your base path, but I guess you meant entire URL.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement