Ionic左右划用来加载上一页,下一页

参考了这篇文章

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

左右划的代码优化了下,去掉遍历:

  $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);
    }

浏览器中测试通过。

猜你喜欢

转载自my.oschina.net/u/1240534/blog/652224