插入HTML与要运行脚本

编程入门 行业动态 更新时间:2024-10-28 15:18:58
本文介绍了插入HTML与要运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

该应用程序的一个组成部分,从需要被显示为现场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与要运行脚本

本文发布于:2023-11-24 08:20:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624453.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!