Skip to content

Instantly share code, notes, and snippets.

@maxca
Created October 14, 2016 04:27
Show Gist options
  • Save maxca/ff0e5cd6af15b46c2c3efd6f81f843d5 to your computer and use it in GitHub Desktop.
Save maxca/ff0e5cd6af15b46c2c3efd6f81f843d5 to your computer and use it in GitHub Desktop.
/** switch env detect */
(function() {
var switchEnv = angular.module('switchEnv', ['useConfigApp']);
switchEnv.service('serviceEnv', ['config','$location', function(config,$location) {
this.env = function(host){
var host = !angular.isUndefined(host) ? host : $location.host();
switch(host) {
case 'local':
return config.local;
break;
case 'staging':
return config.staging;
break;
case 'production':
return config.production;
break;
default:
return config.production;
break;
}
}
}]);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment