I am starting my adventure with Angular2 and I've read lots of tutorials, but there is one thing I am concern about. Lets say we have two views - one with report and one with upload image.
First view will be handled by - let's say 'ReportComponent' and on html template it will use 'Chart.js' library
Second view will be handled by 'UploadMediaComponent' and on html template it will use 'Dropzone.js'
How to include this javascript libraries on html? In most tutorials I've read the only way to resolve it is to include both libraries in the index.html page (which is consistent with single page application pattern). But in the other hand - do we really need load hundreds of external libraries at once and beggining of loading the app even if we need to use it only in one view (one component)? Let's say I just need to use 'Dropzone.js' on only one view, do I need to load it on every html view on client side?
-
I hope this will help you: medium.com/@s_eschweiler/…Ruhul Amin– Ruhul Amin2016-11-28 09:50:47 +00:00Commented Nov 28, 2016 at 9:50
-
Dropzone in angular2: 126kr.com/article/5q2i93rmsteRuhul Amin– Ruhul Amin2016-11-28 09:52:59 +00:00Commented Nov 28, 2016 at 9:52
Add a comment
|
3 Answers
You could add file in your angular-cli.json configuration file.
Example :
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js",
"../node_modules/highcharts/highcharts.js",
"../node_modules/chart.js/dist/Chart.js",
"../node_modules/chart.js/dist/Chart.min.js"
]
directly add all JS build will generate script bundled version , Not needed any imports