德美元角JS C $ÇHTML实体 [英] Decode HTML entity in Angular JS
问题描述
我如何去code HTML文本中采用了棱角分明的JS实体。
我有字符串
&放大器; QUOT; 12.10持续的提交和放大器; QUOT;&安培; QUOT;国产向上和QUOT;&安培; QUOT;样片和放大器。QUOT;
我需要一种方法来解除code本采用了棱角分明的JS。我发现了一个办法做到这一点使用JavaScript href=\"http://stackoverflow.com/questions/10715801/javascript-decoding-html-entities\">但我相信多数民众赞成不会对角工作。需要找回在UI上这将看起来像
原始字符串 ,12.10正在进行提交,由,样品。
您可以使用 NG-绑定-HTML
指令来显示它作为一个html内容与所有的HTML实体去codeD。只要确保包括 ngSanitize
在应用程序的依赖。
的 JAVASCRIPT 的
angular.module('应用',['ngSanitize']) .controller(Ctrl键,功能($范围){
$ scope.html ='和; QUOT; 12.10正在进行提交的与放大器; QUOT;&安培; QUOT;国产向上和QUOT;&安培; QUOT;样品和放大器。QUOT;';
});
的 HTML 的
<机身NG控制器=CTRL>
< DIV NG绑定-HTML =HTML>< / DIV>
< /身体GT;
How do i decode HTML entity in text using angular JS.
I have the string
""12.10 On-Going Submission of ""Made Up"" Samples.""
I need a way to decode this using Angular JS. I found a way to do that using javascript here but I am sure thats wont work for Angular. Need to get back the original string on the UI which would look like
""12.10 On-Going Submission of ""Made Up"" Samples.""
You can use the ng-bind-html
directive to display it as an html content with all the html entities decoded. Just make sure to include the ngSanitize
dependency in your application.
JAVASCRIPT
angular.module('app', ['ngSanitize'])
.controller('Ctrl', function($scope) {
$scope.html = '"12.10 On-Going Submission of ""Made Up"" Samples."';
});
HTML
<body ng-controller="Ctrl">
<div ng-bind-html="html"></div>
</body>
这篇关于德美元角JS C $ÇHTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!