Skip to content

Instantly share code, notes, and snippets.

@DioNNiS
Created February 27, 2016 17:09
Show Gist options
  • Save DioNNiS/8bf29c02cfa09b24cfe1 to your computer and use it in GitHub Desktop.
Save DioNNiS/8bf29c02cfa09b24cfe1 to your computer and use it in GitHub Desktop.
Initiate angular application with server config
(function(angular) {
'use strict';
fetchConfig().then(bootstrapApplication);
function fetchConfig() {
var injector = angular.injector(['ng']);
var $http = injector.get('$http');
return $http.get('config.json').then(function(response) {
var coreModule = angular.module('core');
coreModule.constant('serverConfig', response.data);
});
}
function bootstrapApplication() {
angular.element(document).ready(function() {
angular.bootstrap(document, ['core']);
});
}
}(angular));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment