title: How can I pass back a promise from a service in AngularJS?
body: <p>I have some code in my controller that was directly calling $http to get data. 
  Now I would like to move this into a service. Here is what I have so far:</p>
  
  <p>My service:</p>
  
  <pre><code>angular.module('adminApp', [])
  .factory('TestAccount', function ($http) {
      var TestAccount = {};
      TestAccount.get = function (applicationId, callback) {
          $http({
              method: 'GET',
              url: '/api/TestAccounts/GetSelect',
              params: { applicationId: applicationId }
          }).success(function (result) {
              callback(result);
          });
      };
      return TestAccount;
  });
  </code></pre>
  
  <p>Inside the controller:</p>
  
  <pre><code>   TestAccount.get(3, function (data) {
        $scope.testAccounts = data;
     })
  </code></pre>
  
  <p>How can I change this so rather than passing the result of success back it 
  passes back a promise that I can check to see if it succeeded or failed?</p>