I am looking to retrieve configuration data from the server and store it in the global scope within my AngularJS application. My app operates in multiple modes such as development and production, with different external services being used depending on the mode selected. These services are provided via a REST call from ExpressJS (my server) and stored in configuration files.
Is there a controller function that is automatically called upon startup? How would I go about implementing such a function? Currently, my directory structure looks like this:
Within my directory structure, are global scope variables in AngularJS accessible across modules such as system and auth?
I also have an "init.js" file located in the public directory:
//public/init.js
'use strict';
angular.element(document).ready(function() {
//Fixing facebook bug with redirect
if (window.location.hash === '#_=_') window.location.hash = '#!';
//Then init the app
angular.bootstrap(document, ['mean']);
});
// Dynamically add angular modules declared by packages
var packageModules = [];
for (var index in window.modules) {
angular.module(window.modules[index].module, window.modules[index].angularDependencies || []);
packageModules.push(window.modules[index].module);
}
// Default modules
var modules = ['ngCookies', 'ngResource', 'ui.bootstrap', 'ui.router', 'mean.system', 'mean.testcases','mean.testruns',
'mean.auth'];
modules = modules.concat(packageModules);
// Combined modules
angular.module('mean', modules);