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



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;)


If you use angular-cli, you can add all your external JS files in assets folder. And then in angular-cli.json add them:

"scripts": [

You can do it also with external styles:

"styles": [

And of course you are right, then you need to add in typings.d.ts:

declare var PrayTimes:any;
declare var System: any;
declare var $: any;
declare var moment: any;
declare var Chart: any;


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.