0
我是Angular的新手,并且在Codeigniter中设置了一个REST Api配置的简单示例,该示例返回一个json(默认)线程列表。没问题!
直到我向数据库添加更新。如果我清除/然后再次拨打getThreads
,我会收到相同的物品清单。页面刷新解决了这个问题。我可以在firebug中看到它每页加载只调用一次url:api/example/threadlist/id/'x'
。
function ThreadsCtrl($scope, $http, $templateCache) {
$scope.getThreads = function(id) {
if (!id) { id = 'reset'; }
$http({method: 'GET', url: 'api/example/threadlist/id/' + id, cache: $templateCache}).
success(function(data) {
$scope.threadslist = data; //set view model
}).
error(function(data) {
$scope.threadslist = data || "Request failed";
});
};
我该如何使它总是调用一个新的数据列表,而不是重复使用旧数据。
谢谢!
为什么不ü删除缓存:从你的Ajax调用 –
咄$ templatecache!谢谢。当你复制/粘贴代码时,很容易忽略这样的事情。 –
请接受答案 –