There are no variables in the browser such as environment variables.
The $location service will always receive your current URL. I assume your API may live on a different host.
You can simulate environment variables by storing the configuration in an Angular constant.
app.constant('env', { API_URL: "http://someurl.com:8080/api" });
Then you can enter this constant into your other providers.
app.controller('MyController', function($http, env) { $http.get(env.API_URL); });
Here's a decent article on best practices with constants . The article does not use constants, since it is useful to be able to change the configuration without the need to rebuild the code.
I usually process this to move all instance configuration data to the config.json file and then load it with $http when I load my application.
For example, you may have a configuration file such as this.
{ apiUrl: "http://someurl.com:8080/api" }
Then the Angular service loads.
app.service('Config', function($http) { return function() { return $http.get('config.json'); }; });
Then other services can receive a promise that will reveal the configuration when it is resolved.
app.controller('MyController', function($http, Config) { Config() .then(function(config) { $http.get(config.apiUrl); }); });