title: Angular.js > how to manage configuration
body: <p>I got stuck with passing a configuration to our angular application. My problem is</p>
  
  <ol>
  <li>We have configuration is stored in database, so far it's URL of web service to communicate with</li>
  <li>Page is rendered by PHP</li>
  </ol>
  
  <p>How can I pass URL stored in database to ng-app?</p>
  
  <p>So far I have hard-coded services.js</p>
  
  <pre><code>app.constant('config', {ws_url: 'ws://domain/ws'});
  
  app.factory('wampy', function ($rootScope, config) {
  
    var url =  config.ws_url;
    var ws = new Wampy(url, { autoReconnect: true });
  
    return {
      something: function () {
          console.log(url);   // usage of url
      }
    }
  
  }
  </code></pre>
  
  <p>Then it is included into main html code (index.php)</p>
  
  <pre><code>&lt;head&gt;
    &lt;script type="text/javascript" src="http://dev.local/js/ng/app.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="http://dev.local/js/ng/services.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>But it can be amended / moved to somewhere else.</p>
  
  <p>Any thoughts?</p>