[AngularJS] Promises, handler error. 5. example

The deferred object has a property promise which represents the promise of this task. With this promise we can register an on success and an on failure function. Both functions take a single parameter. The on success function gets the value that was provided by the caller of the resolve method while the on failure function gets the value (reason of failure) provided by the caller of the reject function:

var defer = $q.defer(),
     promise = defer.promise;

promise.then(successFn, errorFn);

 

-------------------Example-----------------

Read More:

http://lostechies.com/gabrielschenker/2014/02/04/angularjspart-11-promises/

posted @ 2014-09-04 04:57  Zhentiw  阅读(287)  评论(0)    收藏  举报