zoukankan      html  css  js  c++  java
  • ionic repeat 重复最后一个时要执行某个函数

    在DOM里ng-repeat那个重复的标签上写ng-init="$last?lastAction($index):''",用三目表达式来判断是不是最后一个,是最后一个就去执行lastAction()函数。

    $scope.lastAction = function(index){

      console.log(index+" is the last one.....")

    }

    当采用ionic ion-slide-box时,当前的slide box上有一部分内容也要进行滚动,比如banner,滚动banner时肯定会触发整个页面的滚动,为了达到滚动banner而不带动整个页面的滚动的目的,可以这样来操作

    $timeout(function(){
            
            document.getElementById('banners').addEventListener('touchstart',function(){
                //console.log('touch start.....')
                $ionicSlideBoxDelegate.$getByHandle('home-box').enableSlide(false);
            });
            document.getElementById('banners').addEventListener('touchend',function(){
                //console.log('touch end.....')
                $ionicSlideBoxDelegate.$getByHandle('home-box').enableSlide(true);
            });
            document.getElementById('banners').addEventListener('touchcancel',function(){
                //console.log('touch cancel.....')
                $ionicSlideBoxDelegate.$getByHandle('home-box').enableSlide(true);
            });
            
        },500)

    所有的数据都是通过异步获取的,所以通过$timeout()来包裹这些事件。当touch banner部分内容区时,禁止整个页面的滚动,当touch结束时,开启整个页面的滚动。还有一个问题要注意,如果是多个同类名的小滚动区域也要实现该功能,如果只是将上面的id名改成classname,是会报错的。

    用上述原生js写的话,需要使用for循环遍历;若是用jQuery,就只需要获取类名

    $timeout(function(){
            var columnList = document.getElementsByClassName("column-list");
            for(var i=0;i<columnList.length;i++){
                columnList[i].addEventListener('touchstart',function(){
                    console.log("start....")
                    $ionicSlideBoxDelegate.$getByHandle('home-box').enableSlide(false);
                });
            }
    //        $(".column-list").on('touchstart',function(){
    //            console.log("start....")
    //        $ionicSlideBoxDelegate.$getByHandle('home-box').enableSlide(false);
    //        });
            $(".column-list").on('touchend touchcancel',function(){
                console.log('touch end.....')
                $ionicSlideBoxDelegate.$getByHandle('home-box').enableSlide(true);
            });
            },500)
  • 相关阅读:
    Android测试提升效率批处理脚本
    iOS系统设备网络抓包工具介绍:越狱和不越狱的办法
    用于管理Linux系统中的各种服务的命令service命令
    linux sort 命令详解
    在loadrunner操作中,所碰见问题及解决方法
    Unable to connect to the remote server 问题(已经解决)
    均值、中位数、众数
    修改Android 界面颜色
    设置Android程序图标和程序标题
    Android中的EditText默认时不弹出软键盘的方法
  • 原文地址:https://www.cnblogs.com/tiantianxiangshang33/p/5905019.html
Copyright © 2011-2022 走看看