我是 Angular 的新手,并在 Codeigniter 中使用 REST Api 配置设置了一个简单的示例,该配置返回一个 json(默认)线程列表。没问题!
直到,我向数据库添加更新。如果我清除/然后getThreads
再次调用,我会收到相同的项目列表。页面刷新解决了这个问题。我可以在萤火虫中看到它只调用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";
});
};
我将如何使它始终调用新的数据列表而不是重用旧数据列表。
谢谢!