Question: 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?

Answer: 
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()
  {
    // ...      
  }
);

```