简体   繁体   中英

angularJS cached data

I have a service does update, add and delete. once update, add or, delete is called, the below code is called immediately to get the updated result.

If there are 10 items and I add one item, the alert increases 1 in my local environment, so it becomes 11. But it stays 10 on the server when it should be 11. If I refresh the page then it updates to 11. Looks like it is cached. How to I change it to get it to load the correct result all the time?

    mySvc.list.promise.then(function(logonArray) {
        $scope.Logons = {data: angular.copy(logonArray)};
        alert($scope.Logons.data.length);
    });

In my case, a developer turned on cache:true in the http get call.

So first check if the cache is turned on.

You will need to remove the cache by doing this $cacheFactory.get('$http').remove(url); after every add/update/delete call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM