【问题标题】:How to use ion-refresher if the page has more than 1 div in ionic 1如果页面在离子 1 中有超过 1 个 div,如何使用离子刷新器
【发布时间】:2017-07-02 16:45:10
【问题描述】:

我想对具有 3 个 div 元素的 html 页面使用 ion-refresher。每个 div 元素将执行不同的功能,例如 allShow()、earnedShow() 和redeemShow()。

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

请提出一种使用方法

      $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>

【问题讨论】:

  • 完全不清楚你在这里问什么。使用您发布的代码,这些div 将永远不可见,因为所有ng-show 都指向不存在的$scope 属性。
  • $scope.All = false; $scope.Earned = false; $scope.Redemed = true;
  • 这些是我用于每个函数以显示各自函数的范围变量。我现在正在获取内容。问题是我只需要刷新那个特定的范围
  • $scope 是每个控制器,而不是每个功能;仍然不清楚您要在这里做什么。

标签: angularjs cordova ionic-framework


【解决方案1】:

您应该根据当前选择的 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);

可能是解决办法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-23
    • 1970-01-01
    相关资源
    最近更新 更多