Skip to content
Advertisement

using external JS libraries in my angular 2 project

I need to use this JS library in my angular 2 project

this question may be duplicate with me , but no answer worked for me

I tried to include the library as script tag in my index.html page

It always does not see it http://localhost:8100/PrayTimes.js file is not exist

also I wrote this code above

declare var PrayTimes:any;

I tried to use it in my constructor , but I am getting this error

PrayTimes is not defined

Advertisement

Answer

Place all javascript, external css, images etc. in src/assets

(will be compiled to build/assets)

In your index.html: <script src="assets/yourJavascript.js"></script>

Then you can just use it like you describe. (declare var PrayTimes: any;)

Advertisement