Angular 12 References/ Templates
🍀 Angular References

Touch events / Gestures

Angular supports Hammer.JS gestures.

Applications need to include the HammerJS script itself.

npm install hammerjs

Import HammerModule at the root of your application so that Angular can work with HammerJS to detect gesture events.

Define lazy Hammer loader provider:

providers: [
    provide: HAMMER_LOADER,
    useValue: async () => {
      return import('hammerjs/hammer');

Or import the library directly to main.ts file:

import 'hammerjs';

After that you will be able to bind gesture events.

<div (swipe)="swipeHandler()">
  Swipe me!
export class AppComponent {
  swipeHandler() {
    alert('Swipe handled!');
Swipe me!
Links & Tutorials