Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
angularjs,这是一个 scope 中带有 html 代码的处理方式。
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<div test ng-bind-html="title"></div>
app.directive('test', function ($sce) {
return {
restrict: 'A',
link: function (scope) {
scope.title = '<h1>大标题</h1>';
scope.toTrusted = function(html) {
return $sce.trustAsHtml(html);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment