title: AngularJS - Wait to Load data to display the view
body: <p>I am really new to AngularJS and after reading several questions and some articles I am a little confused about the correct way to load data and wait till its loaded to display the view.</p>
  
  <p>My controller looks like this</p>
  
  <pre><code>app.controller('ResultsController', ['$scope','$http', '$routeParams', function($scope, $http, $routeParams) {
      $scope.poll = {};
      $scope.$on('$routeChangeSuccess', function() {
          showLoader();
          $http.get("rest/visualizacion/" + $routeParams.id)
            .success(function(data) {
                $scope.poll = data;
                hideLoader();
             })
             .error(function(data) {
                // Handle error
             });
      });     
  }]);
  </code></pre>
  
  <p>I have seen there are people who create a service for $http calls, is it necessary? Why is it better? </p>