简体   繁体   中英

Material 2 for Angular 2 throwing errors

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

在此处输入图片说明

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

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"
]

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM