W3cubDocs

/Angular.js 1.5

Improve this Doc View Source ngClick

  1. directive in module ngTouch
Deprecated: (since v1.5.0)

This directive is deprecated and disabled by default. The directive will receive no further support and might be removed from future releases. If you need the directive, you can enable it with the $touchProvider#ngClickOverrideEnabled function. We also recommend that you migrate to FastClick. To learn more about the 300ms delay, this Telerik article gives a good overview.

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.

Requires the ngTouch module to be installed.

This directive can fall back to using an ordinary click event, and so works on desktop browsers as well as mobile.

This directive also sets the CSS class ng-click-active while the element is being held down (by a mouse click or touch) so you can restyle the depressed element if you wish.

Directive Info

  • This directive executes at priority level 0.

Usage

  • as element: (This directive can be used as custom element, but be aware of IE restrictions).
    <ng-click
      ng-click="expression">
    ...
    </ng-click>
  • as attribute:
    <ANY
      ng-click="expression">
    ...
    </ANY>

Arguments

Param Type Details
ngClick expression

Expression to evaluate upon tap. (Event object is available as $event)

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