AngularJS - 是否有可能采用NG-重复渲染HTML值? [英] AngularJS - Is it possible to use ng-repeat to render HTML values?
问题描述
我使用与生成HTML响应第三方服务AngularJS。我想用NG-重复渲染HTML响应为一个列表,但角使得它为文本。
I'm using AngularJS with a third party service that generates html responses. I want to use ng-repeat to render the HTML responses as a list, however Angular renders it as text.
时有可能使用NG-重复渲染HTML属性?
Is it possible to use ng-repeat to render HTML property?
我已经创造了这个的jsfiddle来证明我的问题。
http://jsfiddle.net/DrtNc/1/
I've created this jsFiddle to demonstrate my issue. http://jsfiddle.net/DrtNc/1/
推荐答案
我认为使用 NG-结合HTML的不安全
会得到你所需要的。
I think using ng-bind-html-unsafe
will get you what you need.
<div ng:repeat="item in items" ng-bind-html-unsafe="item.html"></div>
下面是一个工作小提琴: http://jsfiddle.net/nfreitas/aHfAp/
Here's a working fiddle: http://jsfiddle.net/nfreitas/aHfAp/
有关指令文档可以在这里找到:<一href=\"http://docs.angularjs.org/api/ng.directive:ngBindHtmlUnsafe\">http://docs.angularjs.org/api/ng.directive:ngBindHtmlUnsafe
Documentation for the directive can be found here: http://docs.angularjs.org/api/ng.directive:ngBindHtmlUnsafe
这篇关于AngularJS - 是否有可能采用NG-重复渲染HTML值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!