Hello i tried to recognize swipe left/right and touch gesture on div using Ionic framework:
Documentation:
http://ionicframework.com/docs/api/directive/onSwipeLeft/
Code:
<div class="row" on-swipe-left="alert('right');">
<div class="col" style="background-color: red;">.col</div>
</div>
But this is not working.
How can i easily recognize swipe on given element?
Thanks for any help.
You are using the event directive correctly. The issue is these directives are expecting an expression as their input. The $parse function is used to convert that expression into a function. https://docs.angularjs.org/api/ng/service/$parse
In short. It will only execute functions on your scope. See this codepen for a short example.
http://codepen.io/wedgybo/pen/sgKEb
<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);
}
});