Created
May 8, 2014 03:39
-
-
Save think2011/696746b70d3a4bc70f40 to your computer and use it in GitHub Desktop.
angularjs,这是一个 scope 中带有 html 代码的处理方式。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div test ng-bind-html="title"></div> | |
<script> | |
app.directive('test', function ($sce) { | |
return { | |
restrict: 'A', | |
link: function (scope) { | |
scope.title = '<h1>大标题</h1>'; | |
scope.toTrusted = function(html) { | |
return $sce.trustAsHtml(html); | |
}; | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment