美文网首页
Angularjs html文本显示

Angularjs html文本显示

作者: Lulus | 来源:发表于2017-12-26 13:35 被阅读0次
    <body ng-app="siteApp">
        <div ng-controller="newsDetailController as vm">
            <div ng-bind-html="vm.data.content|to_trusted">
        </div>
    </body>
    
    var app = angular.module('siteApp', []);
    var con = app.controller("newsDetailController", ['$scope', '$http', '$sce', function ($scope, $http, $sce) {
        var vm = this;
        
        vm.data.content="你的HTML文本";
    }]);
    
    /*显示HTML文本*/
    app.filter(
        'to_trusted',
        [
            '$sce', function ($sce) {
                return function (text) {
                    return $sce.trustAsHtml(text);
                }
            }
        ]
    )
    

    相关文章

      网友评论

          本文标题:Angularjs html文本显示

          本文链接:https://www.haomeiwen.com/subject/fuodgxtx.html