title: How to get data from service - data that will be fetched with a delay
body: <p>I have the following service declared:</p>
  
  <pre><code>app.factory('data', ['$http', function ($http) {
  
          var dataRecords = {};
  
          //Retrieve the entries from the data file and categorize them according
          //to the information types located in the overview page
          $http.get('data.json')
              .success(function (records) {
                      //Fill the dataRecords variable
          });
  
          return {
              get: function () {
                  return dataRecords;
              },
              setNew: function (newRecords) {
                  dataRecords = newRecords;
              }
          };
      }]);
  </code></pre>
  
  <p>As can be seen, using <code>$http</code> I fetch the data from the data.json file. Now my issue is that when I call the <code>get</code> method of the data service, I get back empty records even though data.json is not empty.  </p>
  
  <p>As I understand, <code>$http.get()</code> will return the data with some delay and hence when I call get, it is still not filled and hence I get empty values.  </p>
  
  <p>How do I call the service and ensure that the data is filled when I am fetching it from the service?</p>