Created
February 27, 2016 17:09
-
-
Save DioNNiS/8bf29c02cfa09b24cfe1 to your computer and use it in GitHub Desktop.
Initiate angular application with server config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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