我的离子型应用程序使用jsdata数据存储来缓存http://www.js-data.io/docs/home。
我正在尝试使用离子刷新指令在我的应用程序中实现拉式刷新功能。
doRefresh似乎根本不打Get电话。
当我点击拉刷新时,下面代码中的所有console.log消息都会被执行。
然而,如果我检查网络的标签,我没有看到一个Get电话正在进行。
没有数据刷新,也没有任何错误。
我不知道为什么会这样,也不知道我做错了什么。
我的代码:
HTML:
<ion-refresher
pulling-text="Pull to refresh..."
on-refresh="doRefresh()">
</ion-refresher>主计长:
.controller('ProfileInfo', function($scope, Profile) {
$scope.load = function() {
$scope.error = undefined;
Profile.findAll().then(function(response) {
$scope.Profile = response[0];
}).catch(function(err) {
$scope.error = err;
});
};
$scope.load();
$scope.doRefresh = function() {
console.log("hi")
$scope.error = undefined;
$scope.Profile = [];
Profile.findAll().then(function(response) {
console.log($scope.Profile)
$scope.Profile = response[0];
console.log($scope.Profile)
console.log("Done")
}).catch(function(err) {
console.log("err", err)
$scope.error = err;
}).finally(function(){
console.log("in finally")
$scope.$broadcast('scroll.refreshComplete');
});
};
});发布于 2016-10-21 14:36:46
在您的doRefresh方法中,您需要将bypassCache: true传递给findAll all,以强制它尝试发出新的请求。
var query = {};
var options = {
bypassCache: true
};
Profile.findAll(query, options).then(...);阅读更多关于 in JSData 2.x的信息。
https://stackoverflow.com/questions/40171173
复制相似问题