CommonSenseCode
CommonSenseCode

Reputation: 25420

Material 2 for Angular 2 throwing errors

How to deal with this errors of Material 2 for Angular 2:

enter image description here

 client:75 [default] /Users/mateo/Desktop/app/client/node_modules/@angular/material/core/gestures/MdGestureConfig.d.ts:4:39 
Cannot find name 'HammerManager'.

Upvotes: 1

Views: 241

Answers (2)

yurzui
yurzui

Reputation: 214295

You can try the following:

1 Install types for hammerjs:

npm install @types/hammerjs --save-dev

2 Open \node_modules\@angular\material\tsconfig.json and add installed hammerjs types to types array this config:

"types": [
  "hammerjs"
]

enter image description here

Upvotes: 2

BeetleJuice
BeetleJuice

Reputation: 40936

Basically, you need to install HammerJS because you're using Material component that requires it:

npm install hammerjs --save

systemjs.config.js

System.config({
    path: {'npm:' : 'node_modules/'},
    map:  {'hammerjs': 'npm:hammerjs'},
    packages: {
        'hammerjs':  { main: './hammer.js', defaultExtension: 'js'}
    }
})

A few Material components (eg: md-slider) import hammerjs, so unless it's installed or linked via an external script (as in @Gunter's answer), you will run into problems.

Upvotes: 1

Related Questions