简体   繁体   English

AngularJS 中的 HTML 解码

[英]HTML decoding in AngularJS

We are using AngularJS version 1.5.6 and HTML characters are not displayed correctly in text.我们使用的是 AngularJS 1.5.6 版,HTML 字符无法在文本中正确显示。 I've tried many codes but haven't been successful.我尝试了很多代码,但都没有成功。 There are a lot of associated topics in StackOverflow and I've tried most of them, but the HTML code structure still appears. StackOverflow 中有很多相关的主题,我已经尝试了其中的大部分,但是 HTML 代码结构仍然出现。

For example.例如。

2 <sup>3</sup>

Displaying as.显示为。 In more complex HTML codes, unfortunately, even the text is now difficult to read.不幸的是,在更复杂的 HTML 代码中,即使是文本现在也难以阅读。 How can I get HTML codes decoded?如何解码 HTML 代码?

core.js核心.js

app.controller('stockCheckAppController', function ($scope, $http) {
    stockCheckAppLoad(); 
    function stockCheckAppLoad() {
        $http.get("https://example.com/getSto").success(function (stockCheckAppData) {
            $scope.stockCheckAppLoad.innerHTML = stockCheckAppData;
        })
    }
});

app.js:应用程序.js:

var app = angular.module('stockCheckApp', []);
(function () {
    'use strict';
    angular.module('utils.autofocus', [])
        .directive('autofocus', ['$timeout',
            function ($timeout) {
                return {
                    restrict: 'A',
                    link: function ($scope, $element) {
                        $timeout(function () {
                            $element[0].focus();
                        });
                    }
                };
            }
        ]);
})();

index.html索引.html

<h3 class="text-white">{{stockCheckAppData.name}}</h3>

I don't see you injecting module utils.autofocus in module stockCheckApp .我没有看到你注入模块utils.autofocus模块stockCheckApp If you are not aware then you can inject it like this:如果你不知道,那么你可以像这样注入它:

var app = angular.module('stockCheckApp', ['utils.autofocus']);

I had this issues, https://stackoverflow.com/a/10971756/2008962 should solve your problem.我遇到了这个问题, https://stackoverflow.com/a/10971756/2008962应该可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM