参考了这篇文章 浏览器
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