Javascript 当我“;拉动刷新”;,我如何清理缓存?具有离子骨架和AngularJS
我有一个问题,我使用的是来自外部服务器的JSON,但是当我执行“拉刷新”或打开应用程序时,显示的信息与我第一次打开应用程序时下载的信息相同。可能是JSON存储在缓存中,因此没有更新?如果我转到on refresh=“doRefresh()”并调用另一个JSON(我第一次这么做),则更新,但重新输入应用程序,我从第一个JSON加载信息,如果我想要更新,则显示我第一次下载的信息。这将修复手动删除应用程序数据的问题,但这不是最好的方法 这是我的services.jsJavascript 当我“;拉动刷新”;,我如何清理缓存?具有离子骨架和AngularJS,javascript,json,angularjs,cordova,ionic-framework,Javascript,Json,Angularjs,Cordova,Ionic Framework,我有一个问题,我使用的是来自外部服务器的JSON,但是当我执行“拉刷新”或打开应用程序时,显示的信息与我第一次打开应用程序时下载的信息相同。可能是JSON存储在缓存中,因此没有更新?如果我转到on refresh=“doRefresh()”并调用另一个JSON(我第一次这么做),则更新,但重新输入应用程序,我从第一个JSON加载信息,如果我想要更新,则显示我第一次下载的信息。这将修复手动删除应用程序数据的问题,但这不是最好的方法 这是我的services.js angular.module('s
angular.module('starter.services', ['ngResource'])
.factory('NotasService', ['$http',
function ($http) {
var items_nota = [];
var items_nota_array;
return {
all: function () {
return $http.get('http://192.168.1.0:8100/wp-json/posts?filter[post_status]=publish&filter[posts_per_page]=30')
.success(function(data, status, headers, config){
console.log("**** SUCCESS ****");
console.log(status);
})
.error(function(data, status, headers, config){
console.log("**** ERROR ****");
console.log(status);
})
.then(function(response){
console.log("**** THEN ****");
items_nota = response;
return items_nota;
}
)
},
get: function (notaId) {
// Simple index lookup
var pepe = parseInt(notaId);
var ESTO = 0;
var addToArray = true;
for (var i = 0; i < items_nota.length; i++) {
if (items_nota[i].id == pepe) {
addToArray = false;
ESTO = i;
}
}
return items_nota[ESTO];
}
}
}])
谢谢!新年快乐
更新:解决了服务器端缓存中的问题我认为您的问题在于GET查询:
http://192.168.1.0:8100/wp-json/posts?filter[post_status]=publish&filter[posts_per_page]=30
如果添加新数据,请检查此查询是否返回相同的posts事件。您可以使用以下工具进行示例http查询:
post_状态和每页的post_是恒定的
请查收。祝你好运 那么你的问题是什么?我无法获得更新信息,即使JSON(在web上)如果进行了此更新,应用程序中显示的信息与第一次连接到openUPDATE时的信息相同:解决了服务器端缓存中的问题。我尝试了你所说的,并在邮递员上进行了更新,问题仍然存在于应用程序中,无法更新信息。您可以将
$scope.$broadcast('scroll.refreshComplete')在NotasService.all().then(function(data){$scope.items\u nota=data;})
中,@gaffiocchi我遇到了同样的问题。你是如何解决这个问题的?
http://192.168.1.0:8100/wp-json/posts?filter[post_status]=publish&filter[posts_per_page]=30