ngTouch

Improve this Doc ngTouch

Installation

First include angular-touch.js in your HTML:

<script src="angular.js">
<script src="angular-touch.js">

You can download this file from the following places:

  • Google CDN
    e.g. //ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-touch.js
  • Bower
    e.g.
    bower install angular-touch@X.Y.Z
  • code.angularjs.org
    e.g.
    "//code.angularjs.org/X.Y.Z/angular-touch.js"

where X.Y.Z is the AngularJS version you are running.

Then load the module in your application by adding it as a dependent module:

angular.module('app', ['ngTouch']);

With that you're ready to get started!

ngTouch

The ngTouch module provides touch events and other helpers for touch-enabled devices. The implementation is based on jQuery Mobile touch event handling (jquerymobile.com).

See $swipe for usage.

Module Components

Directive

Name Description
ngClick

A more powerful replacement for the default ngClick designed to be used on touchscreen devices. Most mobile browsers wait about 300ms after a tap-and-release before sending the click event. This version handles them immediately, and then prevents the following click event from propagating.

ngSwipeLeft

Specify custom behavior when an element is swiped to the left on a touchscreen device. A leftward swipe is a quick, right-to-left slide of the finger. Though ngSwipeLeft is designed for touch-based devices, it will work with a mouse click and drag too.

ngSwipeRight

Specify custom behavior when an element is swiped to the right on a touchscreen device. A rightward swipe is a quick, left-to-right slide of the finger. Though ngSwipeRight is designed for touch-based devices, it will work with a mouse click and drag too.

Service

Name Description
$swipe

The $swipe service is a service that abstracts the messier details of hold-and-drag swipe behavior, to make implementing swipe-related directives more convenient.

© 2010–2016 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.4.14/docs/api/ngTouch

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部