Book Image

Learning Ionic

By : Arvind Ravulavaru
Book Image

Learning Ionic

By: Arvind Ravulavaru

Overview of this book

Table of Contents (19 chapters)
Learning Ionic
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Gesture directives and services


The next set of directives and services are for gestures. If you did not already know, gestures are actions that a user performs on the screen when interacting with the application. An example of a gesture is pinching to zoom-out or pinching-in to zoom-in (just like on a smartphone).

Ionic supports these gestures and lets you handle them using the $ionicGesture service inside your controller or directive.

To make things more generic, I will explain one gesture directive and show how you can work with it. The same logic applies to all the other gestures.

We will be testing the on-drag-up directive by scaffolding a new blank app; run this:

ionic start -a "Example 26" -i app.example.twentysix example26 blank

Using the cd command, go to the example26 folder and run this:

  ionic serve

This will launch the blank template in the browser.

First, we will create a controller named AppCtrl in www/js/app.js.

.controller('AppCtrl', function($scope, $ionicGesture) {

    $scope...