How do I use hammerjs with Ionic

1k Views Asked by At

I am trying to using hammer js in ionic angular project.

I have imported hammermodule in my component's module:

import { BrowserModule, HammerModule } from '@angular/platform-browser';
//...
@NgModule({
  imports: [
BrowserModule,
HammerModule,
//...
]})

And imported hammerjs inside the component as per docs. But no event is triggered.

<div (swipeleft)="onswipe(i)">swipe me</div>
onswipe(x){
console.log(x,'triggered')
}
1

There are 1 best solutions below

0
saravana priyan On BEST ANSWER

HammerModule should be imported inside AppModule(not inside child modules).

You can import 'hammerjs' inside the components.