Search code examples
javascriptangulartypescriptangular5hammer.js

Hammer.js for Angular 2+


I use hammer.js in my applications (Angular 2 and 5). I use events from this library, as example - tap. If I destroy any DOM-element with the help of *ngIf, there's subscription on the event. As a result, there's a reference to the DOM-object in the memory.

Example

<div class="nnn"
     (tap)="ontp()"
></div>

<ng-container *ngIf="_show">
    <div class="arr"
         *ngFor="let item of _items"
         (tap)="onT()"
    > 
        {{item}} 
    </div>
</ng-container>

How I can remove listener from this DOM-element?

without tap with tap


Solution

  • It is a bug in Angular: https://github.com/angular/angular/issues/22155 Pull request and workaround: https://github.com/angular/angular/pull/22156