Ad Code

Responsive Advertisement

How to use template cache in angularjs

function getQuery(){
var setupCache = $cacheFactory('setupServiceCache');
var deferred = $q.defer();
    var CustomerName = setupCache.get("CustomerName");
    if (!CustomerName || CustomerName.length === 0 ) {
$http({
url: serviceBase + 'GetCustomerName',
            method: "GET",
            params: { locationID: userInfo.locationID }
        ).then(
function (results) {
setupCache.put("CustomerName", results.data);
                deferred.resolve(results.data);
});
} else {
deferred.resolve(CustomerName);
    }
    return deferred.promise;
}


function post(){
return $http.post(url + 'Delete', entity).then(function (result) {
return result;
    }).catch(function (ex) {
    throw ex;
});
}

Post a Comment

1 Comments

Close Menu