If you are building your angular app with a build tool like Gulp, you can control the Base URL of your app at build time. It doesn't allow you to switch Base URLs at runtime, but it would allow you to, say, build an app pointed to your local machine or a server with a single command.
gulpfile.js:
var gulpUtil = require('gulp-util');
var gulpData = require('gulp-data');
var gulpTemplate = require('gulp-template');
var sourceDir = 'path/to/src';
var buildDir = 'path/to/build/target';
gulp.task('default', [],
function() {
return gulp.src(sourceDir + 'index.html')
.pipe(gulpData(function() {
return {
baseUrl : gulpUtil.env.baseUrl
};
}))
.pipe(gulpTemplate())
.pipe(gulp.dest(buildDir));
});
and then in your index.html:
<script>
angular.module('myApp', [])
.provider('appConfigProvider', function () {
return {
$get: function () {
return {
baseUrl: '<%= baseUrl %>'
};
}
};
});
</script>
Then when you run gulp, provide the baseUrl as a command-line argument:
gulp --baseUrl https://my.server.com
This sets an environment variable available inside gulpUtil.env; you can also provide configuration via, say, a props file and gulp-props (though I haven't used it). Configuring angular applications via a single command is one of my favorite uses for taskrunners like Gulp.
Good luck!