Bhetzie Bhetzie - 1 year ago 582
TypeScript Question

Dropzone js Angular 2

I want to use the simple example dropzone js in an angular 2 project:

Is there an easy way to use the js for simple drag and drop functionality? I tried adding installing using:

npm i dropzone --save

And referencing the script from node_modules in index.html, but it doesn't seem to work.


Answer Source

Currently, The easiest way to include an external library into an angular 2 project is as follows:

1) include it in your HTML file as a script tag

<script src="js/your-library.js"></script>

2) To use the library you must add the following to one of your ts/js files:

declare var libraryVar: any;


var libraryVar

Where libraryVar is the name of a function from the library you're including, so for example, to include jQuery, you would use:

declare let $:any;