fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://www.fmpq.com/jscss/jquery/1.4.6/angular.min.js"></script> <script src="http://cdn.static.fmpq.com/libs/angular.js/1.5.0-beta.0/angular-sanitize.min.js"></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> <p ng-bind-html="myText"></p> </div> <script> var app = angular.module("myApp", ['ngSanitize']); app.controller("myCtrl", function($scope) { $scope.myText = "My name is: <h1>John Doe</h1>"; }); </script> <p><b>注意:</b> 该实例包含了 "angular-sanitize.js" 文件, 该文件移除 HTML 中的危险代码。</p> </body> </html>
运行结果