在Angularjs显示html文本,如果按照一般处理它。它只能页中显示没经解释文本。
在ASP.NET MVC添加一个控制器:
pilotApp.controller('ShowHtmlCtrl', ['$scope','$sce', function ($scope, $sce) { var htmltext = "Hello <span style = 'color:red'><b>Insus.NET</b></span>"; $scope.Content = $sce.trustAsHtml(htmltext); }] );
<div ng-app="PilotApp" ng-controller="ShowHtmlCtrl"> <span ng-bind-html="Content"></span> </div>