title: Http Service Factory Returns Undefined to Controller in Angular
body: <p>I have this service, that initialize brands and actualBrand variables. </p>
  
  <pre><code>.factory('brandsFactory', ['$http', 'ENV', function brandsFactory($http, ENV){
  
      var actualBrand = {};
      var brands = getBrands(); //Also set the new actualBrand by default
  
      function getBrands(){
          var URL;
          console.log('MOCKS enable? ' +  ENV.mocksEnable);
          if(ENV.mocksEnable){
             URL = ENV.apiMock + ENV.getBrandsMock;
          }else{
              URL = ENV.apiURL + ENV.getBrands;
          }
  
         $http.get(URL).
          success(function(data){
              console.log('data is :' +  data);
              actualBrand = data[0];
              console.log('Actual brand is ' + actualBrand);
              return data;
          }).
          error(function(){
          console.log('Error in BrandsController');
       });
  
      }
  
      var setActualBrand = function(activeBrand) {
          actualBrand = activeBrand;
      };
  
      var isSetAsActualBrand = function(checkBrand) {
          return actualBrand === checkBrand;
      };
  
      return {
          brands : brands,
          actualBrand : actualBrand
      }; 
  </code></pre>
  
  <p>And my controller looks like this:</p>
  
  <pre><code>/* BrandController to manage the html content of a single brand */
      .controller('BrandCController', function(brandsFactory, $scope){
  
          $scope.brands = brandsFactory.brands;
          console.log('brands in controller is ' + $scope.brands + ' -- ' + brandsFactory.brands);
  
      });
  </code></pre>
  
  <p>The problem in the controller is that it gets undefined in brandsFactory.brands because its loaded before the service.</p>
  
  <p>Why can I do to solve this?
  Im really new in angular and javascript, maybe Im doing lots of thing wrong.
  Any help I would be grateful, thank you.</p>