如果页面在离子1中具有多于1个div,如何使用离子刷新器

时间:2017-07-02 05:51:55

标签: angularjs cordova ionic-framework

我想在一个有3个div元素的html页面上使用ion-refresher。每个div元素将执行不同的函数,如allShow(),earnShow()和redeemShow()。

我正在使用popover组件来过滤我的数据。例如,“全部”将包含所有数据,“已赢”将仅显示已获得的详细信息,“已兑换”将仅显示已兑换的详细信息。我已经在一个单独的HTML中编写了所有视图。我想要的是,当我进入'获得'字段时,如果我试图刷新页面意味着,只有负责该div的函数应该出现,它不应该转到'All'

请建议如何使用此

      $scope.allShow = function()
  {
 $scope.All = true;
 $scope.Earned = false;
 $scope.Redeemed = false; 

  //some function
  }
        $scope.earnedShow = function()
  {
 $scope.All = false;
 $scope.Earned = true;
 $scope.Redeemed = false; 
  //some function
  }
        $scope.redeemShow = function()
  {
 $scope.All = false;
 $scope.Earned = false;
 $scope.Redeemed = true; 
  //some function
  }
  
  $scope.doRefresh = function() {

    console.log('Refreshing!');
    $timeout( function() {

		// $scope.allShow();
    

	   $scope.allShow();
     $scope.$broadcast('scroll.refreshComplete');
    
    }, 500);
      
  };
 <ion-content scroll="true" >

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

 <div  ng-show="All" >All
 </div>
  <div  ng-show="Earned" >Earned
 </div>
  <div  ng-show="Redeemed" >Redeemed
 </div>
</ion-content>

1 个答案:

答案 0 :(得分:0)

您应该根据当前选定的div进行刷新。有很多简单的解决方案,但是对于你的逻辑:

$scope.doRefresh = function() {
  console.log('Refreshing!');
  $timeout( function() {    
    if ($scope.All === true) {
      $scope.allShow();
    }
    if ($scope.Earned === true) {
      $scope.earnedShow();
    }
    if ($scope.Redeemed === true) {
      $scope. redeemShow();
    }
    $scope.$broadcast('scroll.refreshComplete');
}, 500);

可能是解决方案