如何使用角度JS解码文本中的HTML实体。
我有绳子
""12.10 On-Going Submission of ""Made Up"" Samples.""
我需要一种使用AngularJS对此进行解码的方法。我在这里找到了一种使用javascript做到这一点的方法,但是我敢肯定那对Angular无效。需要找回UI上的原始字符串
""12.10 On-Going Submission of ""Made Up"" Samples.""
您可以使用 ng-bind-html 指令将其显示为html内容,并解码所有html实体。只要确保 ngSanitize 在您的应用程序中包括依赖项即可。
ng-bind-html
ngSanitize
演示
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>