参考了这篇文章
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);
}
浏览器中测试通过。