ITPub博客

首页 > IT职业 > IT图书 > ASP.NET MVC下使用显示html

ASP.NET MVC下使用显示html

IT图书 作者:tris42 时间:2021-09-09 09:44:17 0 删除 编辑

在Angularjs显示html文本,如果按照一般处理它。它只能页中显示没经解释文本。

在ASP.NET MVC添加一个控制器:
图片描述

创建angularjs控制器:
图片描述

 

pilotApp.controller('ShowHtmlCtrl', ['$scope','$sce',    function ($scope, $sce) {        var htmltext = "Hello Insus.NET";        $scope.Content = $sce.trustAsHtml(htmltext);    }]);

Source Code

 

视图html:
图片描述

 

             

Source Code

 

程序运行结果:
图片描述

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1551/viewspace-2806698/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    82
  • 访问量
    782