Angularjs html文本显示

it2022-06-24  83

<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); } } ] )

转载于:https://www.cnblogs.com/Lulus/p/8117538.html

相关资源:对angularJs中$sce服务安全显示html文本的实例

最新回复(0)