title: AngularJS wait for simple promise to be resolved
body: <p>I'm really new with AngularJS and WebApi and I can't figure out how to wait for promises to be resolved.</p>
  
  <p>I have a very simple application.</p>
  
  <p>This is my HTML code:</p>
  
  <pre><code>&lt;body ng-app="PersonApp"&gt;
  &lt;div ng-controller="PersonController"&gt;
      &lt;div id="personTable"&gt;
          &lt;table&gt;
              &lt;tr ng-repeat="p in person"&gt;
                  &lt;td&gt;{{ p.surname }}&lt;/td&gt;
                  &lt;td&gt;{{ p.name }}&lt;/td&gt;
                  &lt;td&gt;{{ p.birthDate | date:'yyyy-MM-dd' }}&lt;/td&gt;
                  &lt;td&gt;{{ p.fiscalCode }}&lt;/td&gt;
                  &lt;td&gt;
                      &lt;button type="submit" data-ng-click="edit(p)" class="btn btn-default"&gt;Edit&lt;/button&gt;
                      &lt;button type="submit" data-ng-click="delete(p)" class="btn btn-default"&gt;Delete&lt;/button&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;//.................
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>app.controller('PersonController', ['$scope', 'PersonApp', function ($scope, PersonApp) {
      PersonApp.getPersons($scope);
  </code></pre>
  
  <p>And finally the service:</p>
  
  <pre><code>app.service('PersonApp', ['$http', function ($http) {
      this.getPersons = function ($scope) {
          return $http({
              method: "GET",
              url: "../api/person",
              headers: { 'Content-Type': 'application/json' }
          }).success(function (data) {
              $scope.person = data;
              console.log(data);
          }).error(function (data) {
              console.log(data);
          });;
      };
  </code></pre>
  
  <p>I have tried to insert promises everywhere but I really can't figure it out.</p>
  
  <p>I know this is a really dumb question but I hope you have the patience to give me a simple aswer.</p>
  
  <p>Many thanks in advance!</p>