在我的angular 2项目中使用外部JS库 [英] using external JS libraries in my angular 2 project
问题描述
我需要在我的角度2项目中使用这个JS库
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
我试图将库包含为脚本我的index.html页面中的标签
I tried to include the library as script tag in my index.html page
它总是看不到它 http:// localhost:8100 / PrayTimes.js 文件是
不存在
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
PrayTimes is not defined
推荐答案
将所有javascript,外部css,图片等放入 src / assets
Place all javascript, external css, images etc. in src/assets
(将编译为 build / assets
)
在 index.html
中:< script src =assets / yourJavascript.js>< / script>
然后你可以像你描述的那样使用它。 (声明var PrayTimes:any;
)
Then you can just use it like you describe. (declare var PrayTimes: any;
)
这篇关于在我的angular 2项目中使用外部JS库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!