Ionic左右劃用來加載上一頁,下一頁

參考了這篇文章 瀏覽器

http://blog.ntuanb.com/2015/10/04/ionic-swipe-left-right/ ionic

左右劃的代碼優化了下,去掉遍歷: 測試

  $scope.swipeRight = function swipeRight(id) {
        var ndx = null;
        if(id==1){
            ndx = $scope.pages.length;
        } else{
            ndx = id - 1;
        }
        $location.path('/pages/' + ndx);
    }


    $scope.swipeLeft = function swipeLeft(id) {
        var ndx = null;
        if(id==$scope.pages.length){
            ndx = 1;
        } else{
            ndx = id + 1;
        }
        $location.path('/pages/' + ndx);
    }
優化

瀏覽器中測試經過。 blog

相關文章
相關標籤/搜索