解析HTML里面使用angularJS NG绑定 [英] parse html inside ng-bind using angularJS
问题描述
我在与angularJs问题。我的应用程序从服务器请求一些数据,并从服务器返回的数据值之一是HTML的字符串。我在我这样的角模板绑定它
I'm having issue with angularJs. My application requests some data from the server and one of the values from the data returned from the server is a string of html. I am binding it in my angular template like this
<div>{{{item.location_icons}}</div>
但正如你所期望什么,我看到的不是图标图像,但标记
基本上div的东西看起来像
but as you might expect what I see is not the icons images but the markup basically the stuff in the div looks like
"<i class='my-icon-class'/>"
这不是我想要的。
which is not what I want.
任何人都知道我能做些什么来解析HTML中的transclusion
anyone know what I can do to parse the html in the transclusion
推荐答案
您想要使用 NG-绑定-HTML
和 NG-bind- HTML的不安全
为该样的目的。
You want to use ng-bind-html
and ng-bind-html-unsafe
for that kind of purpose.
The examples are shown here
这篇关于解析HTML里面使用angularJS NG绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!