javascript - 如何将 html 字符串打印为 html

标签 javascript html angularjs text

举个例子,如果我这样做:

var = "<a>Asd</a>";

<span>{{ var }}</span>

字符串打印为文本而不是 html,那么如何打印 html?

最佳答案

你应该使用 ng-bind-html directive .

Creates a binding that will innerHTML the result of evaluating the expression into the current element in a secure way.

<ANY ng-bind-html="{expression}">
   ...
</ANY>

关于javascript - 如何将 html 字符串打印为 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21231630/

相关文章:

javascript - Console.Log 没有在 React 构造函数中被调用

javascript - 如何检查 jqueryUI 自动完成下拉框是否打开

javascript - 不同设备的不同样式表

javascript - 如何将 AngularJS 中的对象推到元素正下方

javascript - 允许仅选择可用值的预定义组合

javascript - 如何在Javascript中按字母顺序将字符串数组拆分为数组集

javascript - 如何使用 javascript 清除 div 中的文本

javascript - 使用 Javascript 的动画下拉 Div 面板

javascript - 网页偶尔显示507存储空间不足

javascript - 如何将标题设置为 <span>/<div> 标签,以便它应该读取数据中的 <br/> 标签并在单独的行中显示工具提示?