码迷,mamicode.com
首页 > 其他好文 > 详细

场景下开发-angular 高级组件(自定义)-显示更多

时间:2017-08-17 17:22:59      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:color   blog   scope   bsp   adl   显示   nbsp   false   size   

//  假如拿到数据少于3条,就只显示数据,

//多于三条,显示更多标记,点击更多显示全部,

//点击收起,回复到第二种状态

 

code1

<div ng-if="!reOver" ng-click="ticMore(‘More‘)"></div>
<div ng-if="tkmore && isOver" ng-click="ticMore(‘More‘)">
        <div class="tricon">更多</div>
</div>
<div ng-if="!tkmore" ng-click="ticMore(‘PackUp‘)">
        <div class="tricon">收起</div>
</div>

 

code2

$scope.tkmore= false;
$scope.tkOver= false;
$scope.tcMore = function(type){
    switch(type){
        case‘loadlist‘:
            $scope.ticketlist = $scope.more(data.ticketlist,"loadlist");
            if($scope.by.length>3){$scope.tkOver= true;}
            $scope.tkmore= true;

            break;
        case‘PackUp‘:
            $scope.ticketlist = $scope.more(data.ticketlist,"PackUp");
            $scope.tkmore= false;
            break;
        case‘More‘:
            $scope.ticketlist = $scope.more(data.ticketlist,"More");
            $scope.tkmore= true;
            break;

    }
}
$scope.tcMore(‘loadlist‘);    

code3

.factory(‘commonfn‘,function($state,$ionicHistory,$ionicScrollDelegate,
        $cordovaToast,$rootScope,$ionicPopup){
//    commonfn.init($scope)
    return{
        init: function($scope){

//            下拉显示
            $scope.more = function(arrList,type,flag,num){
                var num =(num)?num:3;
                var arr =[];
                switch(type){
                    case‘loadlist‘:
                        arr = arrList.slice(0,num);
                        flag = !flag;
                        break;
                    case‘PackUp‘:
                        arr  = arrList.slice(0,num);
                        flag = !flag;
                        $ionicScrollDelegate.resize();
                        break;
                    case‘More‘:
                        arr = arrList;
                        flag = !flag;
                        $ionicScrollDelegate.resize();
                        break;
                    default:
                        break;
                
                }
                return arr;
            }
            
        },
        
        
    }
})

 

场景下开发-angular 高级组件(自定义)-显示更多

标签:color   blog   scope   bsp   adl   显示   nbsp   false   size   

原文地址:http://www.cnblogs.com/alan-alan/p/7382539.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!