移动设备上ionic手势无法使用

3
我是一名有用的助手,可以为您翻译文本。
我正在尝试使用Ionic框架在我的应用程序中实现滑动手势。这段代码在浏览器中运行良好,但在移动设备上安装/运行时没有手势起作用。
以下是我的代码:
app.directive('detectGestures', function ($ionicGesture) {
    return {
        restrict: 'A',

        link: function (scope, elem, attrs) {
            var gestureType = attrs.gestureType;
            $ionicGesture.on('swipeup', scope.reportEvent, elem);
            $ionicGesture.on('swipedown', scope.reportEvent, elem);
            $ionicGesture.on('swiperight', scope.reportEvent, elem);
            $ionicGesture.on('swipeleft', scope.reportEvent, elem);
        }
    };
});

Controller.js

$scope.reportEvent = function (event) {
    alert("1");
    console.log('Reporting : ' + event.type);
    event.preventDefault();

    login();
};

当您从设备上运行它时,是否收到任何错误消息? - novalain
没有返回响应,甚至请求也没有被触发。 - shiva sankar
1个回答

0

我在我的ion-content中进行滑动事件,如下:

<ion-content on-swipe-left="swipe();">

在控制器中:

$scope.swipe = function () {
        $state.go("main.agenda.allEvents");
    }

它已经工作了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接