Ionic refresher not working properly

2019-05-21 16:37发布

问题:

I am developing android app using Ionic framework. I used a <ion-refresher> tag to load the contents dynamically when the user pulls down the page. But it didn't work.

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

My controller code is blow:

$scope.doRefresh = function() {
              $http.get('http://localhost/test/gksfapp_backend.php?action=an').then(function(msg){
                     //never executed.
                     $scope.items=msg.data;
                     })
                     .finally(function() {
                     // Stop the ion-refresher from spinning
                         $scope.$broadcast('scroll.refreshComplete');
               });

How can I make this work?

回答1:

I believe you have simply forgotten the parenthesis after doRefresh

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

Also, here is a working code example. http://codepen.io/ionic/pen/mqolp