AngularJS:在视图中的$ scope变量中渲染HTML [英] AngularJS : Render HTML in $scope variable in view
本文介绍了AngularJS:在视图中的$ scope变量中渲染HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像这样的$ scope变量:
I have a $scope variable like so:
$scope.example = "<h1>Hello</h1>"
当我在视图{{example}}
中输出此内容时,我希望呈现HTML.目前,它输出:
When I output this in my view {{example}}
, I want the HTML rendered. At the moment it outputs:
<h1>Hello</h1>
而不是
我想实现的目标是可能的吗?
Is what I am trying to achieve possible?
推荐答案
应该是
$scope.html = "<h1>Hello</h1>";
和
<div ng-bind-html-unsafe="html"></div>
也请参见 AngularJS:将HTML插入视图
这篇关于AngularJS:在视图中的$ scope变量中渲染HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文