在AngularJS局部模板使用第三方的Javascript?第三方、局部、模板、AngularJS

2023-09-13 04:11:55 作者:我活腻了你快来爱死我

我利用的AngularJS局部模板来创建仪表板。有一个列表查看,当你点击一个项目,它切换到一个项目,详细的部分。

I've making use of AngularJS Partial templates to create a dashboard. There is a listing view and when you click on an item, it switches to an Items-Detail partial.

在项目细节部分,我想通过展示一些RGraph图表。但是,对于我的生活,我无法弄清楚如何做到这一点。

Inside the Items detail partial, I'd like to show some charts via RGraph. However, for the life of me, I can't figure out how to do this.

我似乎无法从部分HTML中调用JavaScript。因此,我认为我需要做的是在控制器,或者创建一个指令?

I can't seem to invoke javascript from inside the partial html. So I think I need to do it in the controller, or maybe create a directive?

我是pretty新AngularJS所以我的理解还是很不成熟,并且有可能被误导。

I'm pretty new to AngularJS so my understanding is still very rudimentary and likely misguided.

推荐答案

AngularJS(jqlite)不支持< script>标签里面的谐音。

AngularJS ("jqlite") doesn't support <script> tags inside partials.

包含jQuery的页面上,但是,它应该工作。需要注意的是jQuery的必须包含AngularJS之前。

Include jQuery on your page, however, and it should work. Note that jQuery must be included before AngularJS.

又见AngularJS:如何使内部角度负载脚本NG-包括哪些内容?