【发布时间】:2016-09-03 01:51:10
【问题描述】:
我们有一个 Ionic 应用程序,它轮询 node/express API。
当应用启动时,它会从 API 中正确获取 JSON 数据。当我们更新数据并再次从 Ionic 应用程序获取数据时,我们仍然会看到应用程序启动时的旧数据。
我们尝试过以多种方式清除 Angular 缓存和 Ionic 缓存,但这似乎没有什么不同。
我们尝试过的事情是:
在模板上$ionicConfigProvider.views.maxCache(0);、cache-view="false",在状态上设置cache: false,尝试通过$state.go($state.currentState, {}, {reload : true});、$ionicHistory.clearHistory();和$ionicHistory.clearHistory();、$route.reload和$window.location.reload访问状态。
控制器:
function contactsController(Contacts, $stateParams) {
var vm = this;
var params = $stateParams.id;
Contacts.getAllContacts.then(function success(response) {
vm.data = response.data;
vm.selectedContact = response.data[params];
});
}
工厂
function contactsFactory($http, $stateParams) {
return {
getAllContacts: $http.get('https://api-call'),
update: function(url) {
$http.patch('https://api-call/update', [$stateParams.id, url]);
},
};
}
快递后端
app.get('/', function (req, res) {
ref.once("value", function(snapshot){
res.send(snapshot.val());
});
});
app.patch('/update', function(req, res) {
var id = req.body[0];
ref.child(id).update({"imageURL": req.body[1]});
});
谢谢
【问题讨论】:
-
您是否尝试在路由和视图上禁用缓存?
-
是的,我们做到了,谢谢。我刚刚更新了帖子以包含我们已经尝试过的所有内容。
标签: angularjs node.js express ionic-framework firebase-realtime-database