如何打印HTML字符串为html [英] How to print html string as html

查看:532
本文介绍了如何打印HTML字符串为html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果只是举例我做的:

  VAR =< A>&性Asd LT; / A>中;<跨度> {{VAR}}< / SPAN>

该字符串如同打印文本而不是HTML,所以我怎么打印HTML?


解决方案

您应该使用 NG-绑定-HTML 指令


  

创建一个绑定,将innerHTML的评估结果
  前pression成以安全的方式在当前元素


 <任何NG绑定-HTML ={EX pression}>
   ...
< / ANY>

If just for example I do:

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

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

The string is printed like text and not as html, so how do I print the html ?

解决方案

You should be using 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>

这篇关于如何打印HTML字符串为html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆