AngularJS provide success callback of a factory method

I have a simple factory that returns a promise after a async.-request.

getUpdates: function(){
    var q = $q.defer();
    $http.get(...)
    .success(function(data, status, headers, config) {
        q.resolve(data);
    })
    .error(function(data, status, headers, config) {
        q.reject(status);
    });
    return q.promise;
}

In my controller I just call the getUpdates-method and receive the promise.

var updates = factory.getUpdates();

How can I provide a success/error functionality of the getUpdates method?

factory.getUpdates().success(function(promise){...}).error(function(err)...

What do I have to add to my getUpdates function?

The $http service already return a promise, there is no need to use $q.defer() to create an another promise in this case. You could just write it like this:

getUpdates: function () {
  return $http.get(...);
}

This way the success() and error() methods will still be available.

Or if you really have a reason why you are using $q.defer(), please include it in the question.

You then function to handle the success and failure of the promise:

factory.getUpdates()
  .then(function(value) {
    // handle success
  }, function(reason) {
    // handle failure
  });

factory.getUpdates().then(
  //onSucess
  function(response)
  {
    // ...  
  },
  //onError

  function()
  {
    // ...      
  }
);