title: Attach Data to Pages $scope During AngularJS App Startup in .run
body: <p>I'm dynamically creating my routes in .run here:</p>
  
  <pre><code>.run(function($http, $rootScope) {
  var mainInfo = null;
  $http.get('thegoods.json').success(function(data) {
      $rootScope.HomeGateway = data.HomeGateway;
      var pages = $.merge($rootScope.HomeGateway.questions, $rootScope.HomeGateway.messages);
      for (var i = 0; i &lt; pages.length; i++) {
          $routeProviderReference.when(pages[i].url, {
              templateUrl: pages[i].view,
              controller: pages[i].controller,
              data: pages[i].data
          })
      }
  });
  </code></pre>
  
  <p>How can I access the data (defined as data: pages[i].data above). Note, I'm not sure if this is completely correct -- but it should serve as a demonstration of what I'm trying to accomplish.</p>
  
  <p>Basically, I grab a JSON file and store it in $rootScope. I then use the $rootScope to dynamically create all the URLs. (Please see <a href="http://blog.brunoscopelliti.com/how-to-defer-route-definition-in-an-angularjs-web-app/" rel="nofollow">http://blog.brunoscopelliti.com/how-to-defer-route-definition-in-an-angularjs-web-app/</a> if you are interested in doing this yourself) I want to be able to access data specific to certain pages without having to search through the JSON data again. I understand that it is an inexpensive operation but I'd like to do it the right way if possible.</p>
  
  <p>Another way of phrasing my question would be.. how can I define each pages $scope at .run when the app first starts?</p>