i'm newbie in Ionic and would like to recognize swipe gestures over the div, but if i'm trying in view something like this it does not working in browser, emulator or in device
<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>
How can i solve it?
Thanks for any advice.
I solved this by moving the action to the controller. You can see the 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>
In your accompanying javaScript file...
angular.module('ionicApp', ['ionic'])
.controller('AppCtrl', function($scope,$window) {
$scope.myAlert = function()
{
$window.alert('right');
}
});
Note that injecting $window is not required, but it does making unit testing easier down the line.