zoukankan      html  css  js  c++  java
  • ionic下拉加载自动触发

      ionic提供的下拉加载,是要滑动去下拉加载,没有提供api自动触发下拉加载,比如刚进页面,或者切换tab时想触发一次下拉加载。

      添加如下service:

      

    angular.module('YourApp').service('utilities', function() {
    
        this.triggerScrollViewPullToRefresh = function (scrollView) {
            scrollView.__publish(
                scrollView.__scrollLeft, -scrollView.__refreshHeight,
                scrollView.__zoomLevel, true);
    
            var d = new Date();
    
            scrollView.refreshStartTime = d.getTime();
    
            scrollView.__refreshActive = true;
            scrollView.__refreshHidden = false;
            if (scrollView.__refreshShow) {
                scrollView.__refreshShow();
            }
            if (scrollView.__refreshActivate) {
                scrollView.__refreshActivate();
            }
            if (scrollView.__refreshStart) {
                scrollView.__refreshStart();
            }
        }
    });

     然后在你的controller里添加方法:

      

    angular.module('YourApp').controller('YourController',
      function($scope, $ionicScrollDelegate, utilities) {
        $scope.someFunc = function() {
          // scrollerHandle should be the delegate-handle set on the scrollview
          $scope.scrollDelegate = $ionicScrollDelegate.$getByHandle('scrollerHandle');
          utilities.triggerScrollViewPullToRefresh($scope.scrollDelegate.getScrollView());
        };
      });

     只要在你想触发的地方调用$scope.someFunc 就可以触发下拉刷新

  • 相关阅读:
    MSDN相关下载地址
    显示代码的博客
    unittest 结合 ddt
    python 学习2 测试报告
    python pytest
    Yaml 的python 应用
    linux 面试题
    面试 常见问题
    Python 内建的filter()函数用于过滤序列。
    python reduce & map 习题
  • 原文地址:https://www.cnblogs.com/johnzhu/p/5884247.html
Copyright © 2011-2022 走看看