解析HTML里面使用angularJS NG绑定 [英] parse html inside ng-bind using angularJS

查看:161
本文介绍了解析HTML里面使用angularJS NG绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与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屋!

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