title: How to call service at startup in Angularjs
body: <p>I want to get config from server and store in global scope in angularjs. I run my app in multiple modes ie development mode and production mode. I interact with few external services which are defferent based on the mode I am in. I can provide then through a rest call to angularjs from expressjs(my server). They are stored in config files of my expressjs.</p>
  
  <p>Is there any controller function which get called at startup? How do I write such a function. Currently my directory structure is</p>
  
  <p><img src="https://i.stack.imgur.com/vZlqF.png" alt="enter image description here"></p>
  
  <p>is my directory structure. Are global scope variables in angular js accessible across mudules etc system and auth in above directory?</p>
  
  <p>I also have a init.js in public</p>
  
  <pre><code>//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);
  </code></pre>