title: Accessing parent controller $scope data after load in angular
body: <p>I have the following situation in angular:</p>
  
  <ol>
  <li>I load json data from a database on init() to a variable "data" and would like to use the variable "data" in a child controller (nested). </li>
  <li>Because the loading from the database takes some time, the variable $scope.data in the child controller outputs as "undefined".  </li>
  </ol>
  
  <p>What is an elegant way to handle this situation? Do I need to use a promise on parent's init method inside the child controller? I would appreciate an example :).</p>
  
  <pre><code>// Parent Controller
  app.controller('pCTRL', function($scope) {
    $scope.init = function(id){} 
    //sets my variable $scope.data successfully via a rest API
    //and for test, sets $scope.x to "blabla"
  }
  
  //Child Controller
  app.controller('cCTRL', function($scope) {
  console.log($scope.x); //outputs blabla properly
  console.log($scope.data); // undefined
  </code></pre>
  
  <p>Thank you for your feedback!</p>