该应用程序的一个组成部分,从需要被显示为现场HTML服务器获取HTML回来。这是很容易与做NG绑定HTML的不安全=前pression指令(在角1.0.2至少)。
One part of this app gets HTML back from the server that needs to be shown as live HTML. That's easily done with the ng-bind-html-unsafe="expression" directive (in Angular 1.0.2 at least).
但是,HTML也有应该运行,因为它定义在HTML中使用JavaScript的功能,这似乎并没有使用该指令的情况发生。
However, the HTML also has JavaScript that should run, since it defines functions used in the HTML, and that doesn't seem to happen using the directive.
有一些角式的方式来做到这一点?还是需要摸索出来的带外脚本加载技术?
Is there some Angular-style way to do that? Or do I need to explore out-of-band script loading techniques?
(请让我们不讨论我是否应该信任服务器足以运行Java的脚本,它寄给我。我信任的服务器,我知道的风险,这是一个非常特殊的情况。)
(Please let's not discuss whether I should trust the server enough to run java-script it sends me. I do trust the server, I'm aware of the risks, and this is a very specialized situation.)
推荐答案您需要的jQuery(前角加载它):
You need jQuery (load it before Angular):
我们看着在jqlite支持脚本标记,但需要做的事情得到一个跨浏览器支持什么涉及到很多的黑魔法。为此,我们决定,现在我们只是要建议用户使用jQuery的一起在这种情况下的角 - groups.google/d/msg/angular/H4haaMePJU0/5seG803by5kJ
"we looked into supporting script tags in jqlite, but what needs to be done to get a cross-browser support involves a lot of black magic. For this reason we decided that for now we are just going to recommend that users use jquery along with angular in this particular case" -- groups.google/d/msg/angular/H4haaMePJU0/5seG803by5kJ
又见AngularJS:如何使内部角度负载脚本NG-包括哪些内容?
更多推荐
插入HTML与要运行脚本
发布评论