В моем ионном приложении используется хранилище данных jsdata для кэширования http://www.js-data.io/docs/home .
Я пытаюсь реализовать функцию pull to refresh в своем приложении с помощью директивы ion-refresher.
ионное обновление с jsdata не работает
DoRefresh, похоже, совсем не вызывает вызов.
Когда я нажимаю на Pull для обновления, все сообщения 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');
});
};
});
Это сработало! Благодаря!! :) –