如何显示&安培; NBSP;或任何原始的HTML的角度数据? [英] How to display   or any raw html in angular data?
本文介绍了如何显示&安培; NBSP;或任何原始的HTML的角度数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何显示&放大器; NBSP;
的空间并不如字符串。有原材料
过滤像树枝?
How can I display
as space not as string. Is there raw
filter like in twig?
<div>{{item}}</div>
$scope.item = ' ';
但结果却逃脱了&放大器;放大器; NBSP;
。我需要这个,因为有高度为0。
But the result is escaped &nbsp;
. I need this because ' '
have height of 0.
推荐答案
这可以通过使用的 ngBindHtml
It can be easily done by using ngBindHtml
对于角度的1.2.x以上的版本:
使用 NG-绑定-HTML
Working Demo
HTML
<div ng-app='myApp' ng-controller="Controller">
<div ng-bind-html="item"></div>
</div>
剧本
var app = angular.module('myApp', ['ngSanitize']);
app.controller('Controller', function ($scope, $sce) {
$scope.item = 'What Is Your Name?';
});
角形1.0.x的版本:
Working Demo
使用 NG-结合HTML的不安全
HTML
<div ng-app='myApp' ng-controller="Controller">
<div ng-bind-html-unsafe="item"></div>
</div>
剧本
var app = angular.module('myApp', []);
app.controller('Controller', function ($scope) {
$scope.item = 'What Is Your Name?';
});
这篇关于如何显示&安培; NBSP;或任何原始的HTML的角度数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文