2016-10-21 8 views
1

私のionicアプリケーションはキャッシュにjsdataデータストアを使用しますhttp://www.js-data.io/docs/home
私はイオンリフレッシャー指令を使用してアプリでリフレッシュ機能を実装しようとしています。
jsdataによるイオンリフレッシュは機能しないようです

doRefreshはGet Callを作成していないようです。
[Pull]をクリックして更新すると、以下のコードのすべてのconsole.logメッセージが実行されます。
しかし、ネットワークのタブをチェックすると、Getコールがまったく行われません。
データは更新されず、エラーも発生しません。
なぜこれが起こっているのか、私が間違っているのか分かりません。

マイコード:

HTML: 
<ion-refresher 
      pulling-text="Pull to refresh..." 
      on-refresh="doRefresh()"> 
    </ion-refresher> 

コントローラー:あなたのdoRefreshメソッド内

.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'); 
     }); 
    }; 

}); 

答えて

1

、あなたは、例えば、新しい要求を作成してみてくださいそれを強制するためにfindAllすべてにbypassCache: trueを渡す必要があります

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

behavior of DS#findAll in JSData 2.xについてさらに読む。

+0

それがうまくいった!ありがとう!! :) –

関連する問題