title: How can I delay the ng-init method until my scope Variable finished loading?
body: <p>In my project I have a table with multiple cells. In each cell I have a dropdown menu with an initial value. When the page load, I call a function in <code>ng-init</code> which returns the correct value for this dropdown menu.</p>
  
  <p>My Problem is, that this function depends on a value I get through an asynchronus call to a server. That means sometimes (if the table is large), the necessary data is loaded <strong>after</strong> the ng-init. This way I can't initialize my dropdowns correctly. </p>
  
  <p>So basically I just need a way to be sure that when ng-init is called, all data has already been received from the server.</p>
  
  <p>Normally I would use a $scope variable to simply update the view after I got all the data from the server, but I can't do it here, because I would need a $scope variable for each cell in the table and the table has dynamic width and heigth.</p>
  
  <p>Any ideas how to solve this?</p>
  
  <p>Here is a brief code example of what i mean:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div&gt;
    &lt;md-select ng-model="connectionType"
               ng-init="connectionType = ctrl.getConnectionType(person1.id, person2.id)"
               placeholder=""
               class="md-no-underline"&gt;
  
              &lt;!-- Options --&gt;
   &lt;/md-select&gt;
  </code></pre>
  
  <p></p>
  
  <p>Javascript to load the data from the server:</p>
  
  <pre><code>dataService.getPersons(curView, function(result) {
    var persons = JSON.parse(result);
  
    if (persons.length) {
  
      for (var i = 0;i &lt; persons.length; i++) {
        $scope.persons.push(persons[i]);
          $scope.$apply();
        }
      }
      });
  </code></pre>
  
  <p>Javascript to init the dropdown:</p>
  
  <pre><code>self.getConnectionType = function(id1, id2) {
  
          for (var i = 0; i &lt; $scope.persons.length; i++) {
              if ($scope.persons[i].sourceId === id1&amp;&amp; $scope.persons[i].id2=== activityId) {
                  return $scope.persons[i].connectionType;
              }
          }
      };
  </code></pre>