ионное обновление с jsdata, похоже, не работает

Мое приложение ionic использует хранилище данных jsdata для кэширования http://www.js-data.io/docs/home.
Я пытаюсь реализовать в своем приложении функцию обновления по запросу с помощью директивы ion-refresher.

Похоже, что doRefresh вообще не выполняет вызов Get.
Когда я нажимаю «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');
        });
    };

});

person javascript novice    schedule 21.10.2016    source источник


Ответы (1)


Внутри вашего doRefresh метода вам нужно передать bypassCache: true findAll all, чтобы заставить его попробовать сделать новый запрос, например

var query = {};
var options = {
  bypassCache: true
};
Profile.findAll(query, options).then(...);

Узнайте больше о поведении DS#findAll в JSData 2.x.

person jdobry    schedule 21.10.2016