In a config block, use angular.injector to create a temporary injector to instantiate a $location service. Then use that to create the myConfig constant.
angular.module('myApp').config(function($provide) {
function tempRootElementProvider ($provide) {
$provide.value("$rootElement", angular.element(document));
}
var tempInjector = angular.injector(['ng', tempRootElementProvider]);
var tempLocation = tempInjector.get('$location');
$provide.constant('myConfig', {
'searchUri': tempLocation.absUrl() + "e/_search?pretty",
'version': 0.2
});
})
The $location service also depends on $rootElement, so that needs to be added as a dependency in the temporary injector.
The DEMO on JSFiddle.
$locationProvider, but not $location itself. Depending on what you want to do, it may be better to userunto grab values from$locationand store them in a factory/service.