无法识别离子滑动手势

时间:2014-09-13 19:56:46

标签: android ionic-framework gestures

我是Ionic的新手,想要识别div上的滑动手势,但如果我正在尝试查看类似这样的内容,则无法在浏览器,模拟器或设备中使用

<ion-view title="Charts - days">
  <ion-content class="padding">
    <h1>dede</h1>
      <div class="row" on-touch="alert('right');">
          <div class="col" on-touch="alert('right');" style="background-color: red;">.col</div>
      </div>
      <button on-touch="alert('touch');" class="button">Test</button>

  </ion-content>
</ion-view>

我该如何解决?

感谢您的任何建议。

1 个答案:

答案 0 :(得分:0)

我通过将动作移动到控制器来解决这个问题。您可以看到CodePen here

<ion-view title="Charts - days">
  <ion-content class="padding">
    <h1>dede</h1>
      <div class="row" on-touch="myAlert()">
          <div class="col" on-touch="myAlert()" style="background-color: red;">.col</div>
      </div>
      <button on-touch="myAlert()" class="button">Test</button>    
  </ion-content>
</ion-view>

在随附的javaScript文件中......

angular.module('ionicApp', ['ionic'])
.controller('AppCtrl', function($scope,$window) {
  $scope.myAlert = function()
  {
    $window.alert('right');
  }  
});

请注意,不需要注入$ window,但它确实使单元测试变得更容易。