$httpDeferredExtender

This method turns standard $q promises into $http compatible promises that have .success() and .error() methods.

This is useful in order to get consistent results when using cached values rather than $http requests to retrieve data and have that data look and act just like an $http request.

ww.angular.parseHttpError(deferred)

Return Value

A promise that includes .sucess() and .error() functions.

Parameters

deferred
A $q.deferred instance that you want to turn into an $http compatible promise.

Example

var d = ww.angular.$httpDeferredExtender($q.defer());
service.getAlbums()
    .success(function (albums) {
        service.album = findAlbum(id);
        if (!service.album)
            d.reject(new Error("Couldn't find album"));
        else
            d.resolve(service.album);
    })
    .error(function (err) {
        d.reject(new Error("Couldn't find album"));
    });

// promise that includes .success() and .error()
return d.promise;

See also:

Class ww.angular.js

© West Wind Technologies, 1996-2016 • Updated: 03/31/15
Comment or report problem with topic