title: Angular 1: Defer html rendering after http call
body: <p>In my Angular controller I have a http call to a REST service that returns data in a database. This data are shown in a table in the partial view. </p>
  
  <p>It happens random that the render of the html view is done before to get the callback with data, so I see a void table. </p>
  
  <p>Here the code in the controller (I use services for some business logic and to implement the http call): </p>
  
  <pre><code>commonServices.find(vm.modelUri, null, vm.filter, function (err, msg, data) {
  
              if (err || !data.length) {
                  $scope.noResults = true;
                  return;
              }
  
              $scope.docs = data; //docs is bind in the view 
              return;
          });
  </code></pre>
  
  <p>Here the service for the http call: </p>
  
  <pre><code>function _commonServices(config, $http, $rootScope, $cookies) {
        return {
              find: function _find(modelUri, id, filter, callback) {
                     var url = config.servicesUri + '/' + modelUri;
  
                     if (id) {
                        url += '/' + id;
                     }
  
  
                     if (filter) {
                     if (typeof filter !== 'string') {
                         filter = JSON.stringify(filter);
                     }
  
                     url += '?filter=' + filter;
                     if (document.cookie) {
                         url += '&amp;' + accessToken;
                    }
                    } else {
                      if (document.cookie) {
                         url += '?' + accessToken;
                      }
                    }
  
                    $http.get(url)
                      .then(function (data) {
                      //success
                      return callback(null, null, data.data);
                     },
                     function (data) {
                         //error
                        var err = true;
                      return callback(err, data.data.error.message);
                    });
               }
        }
  </code></pre>
  
  <p>}</p>
  
  <p>The find service is used in other controllers and it seems it works good. I would know if it is possible to defer the render of the html table until the data are ready to be shown. </p>