I am very new to angular JS and working on a mobile application. As a part of it, I need to write a service that handles touch events like swipe-left, swipe-right, swipe-up and swipe down and I need to call back depending on which action is made. Please let me know if there any useful tutorials.
Asked
Active
Viewed 2.2k times
6
-
What you are looking for is already available in angular-touch. Take a look at https://docs.angularjs.org/api/ngTouch – TMichel Jun 25 '14 at 06:15
3 Answers
9
As mentioned in the comments ngTouch is a good place to start, however it only has swipe left and swipe right. I recommend using Angular Gestures; it's an angular implementation of hammer.js, and has pretty much everything you'd ever need:
- doubletap
- dragstart
- drag
- dragup
- dragdown
- dragleft
- dragright
- dragend
- hold
- pinch
- pinchin
- pinchout
- release
- rotate
- swipe
- swipeup
- swipedown
- swipeleft
- swiperight
- tap
- touch
- transformstart
- transform
- transformend

SgtPepper43
- 544
- 3
- 15
2
Another option is the angular-swipe module. It replaces ng-swipe
and uses the same directives, adding up and down:
ng-swipe-up
ng-swipe-down
ng-swipe-left
ng-swipe-right

Bradley Flood
- 10,233
- 3
- 46
- 43
1
In html i used 5 tabs and i am able to swipe left or right smoothly. my code given below.
RECEIVED | SENT | DELETED | ARCHIVED Reports
In html
ng-swipe-left="leftTab()" ng-swipe-right="rightTab()"
and In controller.
$scope.leftTab = function(){
if($scope.tab != 4 ){
$scope.getAlertsSummary($scope.tab + 1);
}
};
$scope.rightTab = function(){
if($scope.tab != 0 ){
$scope.getAlertsSummary($scope.tab - 1);
}
};
Here getAlertsSummary used for get tab data.

Ramu Agrawal
- 21
- 4