自信中国人 发表于 2015-9-21 18:41:24

on-swipe-right 和on-swipe-left到底支不支持啊?

看到好几个地方都有代码示例,结果发现根本不起作用啊;
http://stackoverflow.com/questions/25834611/ionic-swipe-on-div-how-to-trigger
<div ng-controller="SwipeCtrl" class="row" on-swipe-left="alert('right');">
      <div class="col" style="background-color: red;">.col</div>
</div>



angular.controller('SwipeCtrl', function ($scope) {
    $scope.alert = function(msg) {
      alert(msg);
    }
});
http://ionicframework.com/docs/api/directive/onSwipeRight/
<button on-swipe-right="onSwipeRight()" class="button">Test</button>

感觉就是个很简单的东西嘛,怎么也不起作用

自信中国人 发表于 2015-9-21 19:10:00

Cordova CLI: 5.3.1 Ionic CLI Version: 1.6.4 Ionic App Lib Version: 0.3.8 OS: Windows 8 Node Version: v0.10.37

你懂的 发表于 2015-9-21 22:38:12

写在controller里面 不要和controller 同级试试


这个100%是有效的

自信中国人 发表于 2015-9-22 11:37:05

本帖最后由 自信中国人 于 2015-9-22 11:39 编辑

测试一把 发表于 2015-9-21 22:38
写在controller里面 不要和controller 同级试试



不要和controller 同级是什么意思?
.controller('SwipeCtrl', function ($scope) {
    $scope.alert = function(msg) {
      alert(msg);
    }
});
这个alert不就是在controller里面么?

把on-swipe-left改成ng-on-click就可以触发——点击触发,不是左滑。

自信中国人 发表于 2015-9-22 14:38:51

测试一把 发表于 2015-9-21 22:38
写在controller里面 不要和controller 同级试试




解决了,升级ionic到最新版本就好了,之前0.9的不支持
页: [1]
查看完整版本: on-swipe-right 和on-swipe-left到底支不支持啊?