title: Best practice transferring list data from controller to the another controller
body: <p>I want to display view once the list of content is retrieved from the database display it in the view.</p>
  
  <p>On a high level what I am doing now works more or less but upon first access the previous results appears to be cached or still saved in my storage service.</p>
  
  <p>This is what the service looks like.</p>
  
  <pre><code>function StorageService() {
  
      var opportunities;
  
      var getOpportunities = function() {
          return opportunities;
      }
      var setOpportunities = function(data) {
          opportunities = data;
      }
      return {
          getOpportunities: getOpportunities,
          setOpportunities: setOpportunities
      }
  }
  </code></pre>
  
  <p>So when I click on the tab to getOpportunities I go direct to the view first and the load the data.</p>
  
  <pre><code>$scope.getAllOpportunities = function() {
  $state.go("app.opportunities");
  communicationService.getOpportunitiesAll().then(function(data) {
      StorageService.setOpportunities(data);
      if (!data.length) {
          $("#noShow").html("There are no opportunities");
      }
  }, function(error) {})
  </code></pre>
  
  <p>}</p>
  
  <p>once the view is rendered I retrieve the results and bind it to the view.</p>
  
  <pre><code>controller('OpportunitiesController', function($scope) {
  
  $scope.$on("$ionicView.afterEnter", function(scopes, states) {
      $scope.opportunities = StorageService.getOpportunities();
  });
  </code></pre>
  
  <p>What I am doing here also feels a bit wrong.</p>
  
  <p>Is there a better way or a way that I can improve on the existing.</p>
  
  <p>I want to load the view and the replace the loader with the data once the data is ready.</p>
  
  <p>Thanks in advance </p>