var app = angular.module('plunker',['ngSanitize']); app.directive('toHtml',function() { return { restrict: 'A',link: function (scope,el,attrs) { el.html(scope.$eval(attrs.toHtml)); } }; }); 使用方法: <p to-html="name"></p>原文链接:https://www.f2er.com/angularjs/145862.html