Angular-1.1.2. tab页

1.1.2tab页展示

知识点:

理论上 $index 是由 ng-repeat 创建的一个 “模板变量(template variable)”。

这只在 repeat 块里面有意义(并正确起作用)。 当我们将它的值传递到外面时,它就失去了上下文从而不再有效。

 

功能

代码参考

VM

<!-- $scope.tab =[全部,待发货,待收货,已完成] -->

 

<ul class="row bg_fff" id="order_tab">

<li class="item col-25 "  ng-repeat="item in tab" ng-click="queryOrder($index)">

<span  ng-class="slectIndex==$index ? 'active' : ''">{{item}}</span>

</li>

</ul>

M

$scope.items=[];//显示

$scope.items0 =[];//全部

$scope.items1 =[];//待发货

$scope.items2 =[];//待收货

$scope.items3 =[];//已完成,可再去消费

 

$scope.queryOrder = function (index){

  var type =  $scope.slectIndex = index;

  console.log($scope.slectIndex);

   queryOrderByIndex(index,"0",$scope.items0);

   queryOrderByIndex(index,"1",$scope.items1);

   queryOrderByIndex(index,"2",$scope.items2);

   queryOrderByIndex(index,"3",$scope.items3)

}

factory

    .factory('commonfn',function($state,$ionicHistory,$ionicScrollDelegate,

        $cordovaToast,$rootScope,$ionicPopup){

//    commonfn.init($scope)

    return{

        init: function($scope){

//点击tab 查询订单    

$scope.noData1 = function (arr){

  if(arr.length>0){$scope.noData = false;}

  else{

    $scope.noData = true;

    $scope.loadingMore = false;

  }

}   

 

$scope.queryOrderByIndex = function (index,str,arr){

  if(index == str){

    $scope.slectIndex = index;

    $scope.items = arr;

    noData1($scope.items);

  }

  

}

 

            

        },

        

        

    }

})

 

 
posted @ 2017-08-21 10:21  alan-alan  阅读(270)  评论(0编辑  收藏  举报