1

I'm trying to integrate Angular's material design and I'm the following the official documentation.
I have installed the compnents and hammerJS using npm:
npm install --save @angular/material
npm install --save hammerjs
And in my app.module.ts I have called the MaterialModule and hammerjs:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MaterialModule } from '@angular/material';

import { AppComponent }  from './app.component';
import { HeaderComponent } from './comps/header.component';
import 'hammerjs';

@NgModule({
  imports:      [ BrowserModule, MaterialModule ],
  declarations: [ AppComponent, HeaderComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { } 

But the console gives me this error:

GET http://localhost:3000/hammerjs 404 (Not Found)

What am I missing here ?

SlimenTN
  • 3,383
  • 7
  • 31
  • 78

1 Answers1

0

If it's simply a JS library, you can add it as a script in your index.html file.

You would typically import it if there is a typings for it, but I wouldn't import just a JavaScript file.

Look in your node_modules folder and add something like:

<script src="node_modules/hammerjs/... .js"></script>
Bhetzie
  • 2,852
  • 10
  • 32
  • 43
  • 2
    Thank you this did the trick. But why this is not mentioned in the official documentation !! That's really weird. – SlimenTN Mar 03 '17 at 14:40
  • 1
    I think it's because depending which framework you use there are different ways to add external libraries. This is the easiest way and you can reference specific functions in a component like: declare var functionName; I think there are typically better and more recommended ways to add these libraries though; depends on what you are using – Bhetzie Mar 03 '17 at 14:46