title: How can I use angularjs promise chain in a service and controller?
body: <p>I found this plnkr link on the web but I need use it with 2 or 3 more ajax calls which doesn't require an argument from the first ajax call. How can I do it with error handling?</p>
  
  <pre><code>var app = angular.module("app", []);
  
  app.service("githubService", function($http, $q) {
  
    var deferred = $q.defer();
  
    this.getAccount = function() {
      return $http.get('https://api.github.com/users/haroldrv')
        .then(function(response) {
          // promise is fulfilled
          deferred.resolve(response.data);
          return deferred.promise;
        }, function(response) {
          // the following line rejects the promise 
          deferred.reject(response);
          return deferred.promise;
        });
    };
  });
  
  app.controller("promiseController", function($scope, $q, githubService) {
  
    githubService.getAccount()
      .then(
        function(result) {
          // promise was fullfilled (regardless of outcome)
          // checks for information will be peformed here
          $scope.account = result;
        },
        function(error) {
          // handle errors here
          console.log(error.statusText);
        }
      );
  });
  </code></pre>
  
  <p><a href="http://plnkr.co/edit/kACAcbCUIGSLRHV0qojK?p=preview" rel="nofollow">http://plnkr.co/edit/kACAcbCUIGSLRHV0qojK?p=preview</a></p>