$httpPromiseFromValue

Function that creates a resolved or rejected $http compatible promise. Useful for returning result values that are cached to have the same signature as a promise that actually performs async work.

ww.angular.$httpPromiseFromValue($q,val,reject)    

Example

function getAlbums(noCache) {
    // check for cached content and return existing value as a promise
    if (!noCache && service.albums && service.albums.length > 0) 
        return ww.angular.$httpPromiseFromValue($q, service.albums);
        
    return $http.get("../api/albums/")
        .success(function (data) {                    
            service.albums = data;                   
        })
        .error(onPageError);
}

See also:

Class ww.angular.js

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