title: Calling service for factory in controller
body: <p>I have a problem when calling a service created using .factory in my controller.
  The code looks like the following.
  Factory (app.js):</p>
  
  <pre><code>.factory('Database',function($http){
  
      return {
  
        getDatabase: function(){
  
          var database = {};
  
          $http.get('http://localhost:3001/lookup').
            success(function(data){
  
              database.companyInfo = data.info.companyInfo;
              });
  
  
            }).
            error(function(data){
              console.log('Error' + data);
            });
  
          return database;
  
        }
      };
    })
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>angular.module('webClientApp')
      .controller('MainCtrl', function (Database,Features,$scope,$http) {
  
  
  
  
          $scope.databaseString = [];
          $scope.quarters = ['Q1','Q2','Q3','Q4'];
          $scope.years = ['2004','2005','2006','2007','2008','2009','2010',
        '2011','2012','2013','2014'];
          $scope.features = Features.getFeatures();
          $scope.database = Database.getDatabase();
  
          console.log($scope.database);
  </code></pre>
  
  <p>Now when I inspect the element in Firebug I get the <code>console.log($scope.database)</code> printed out before the GET statement result. <code>$scope.database</code> is shown as an <code>Object {}</code> with all the proprieties in place.
  However if I try to use <code>console.log($scope.database.companyInfo)</code> I get an <code>undefined</code> as result, while instead I should get that <code>data.info.companyInfo' that I passed from the</code>Database` service (in this case an array).</p>
  
  <p>What is the problem here? Can someone help me?
  (If you need clarifications please let me know..)</p>