Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55e1b3e

Browse files
committed
docs($sanitize): update example to use a module
1 parent 6f465a2 commit 55e1b3e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/ngSanitize/sanitize.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,21 @@ var $sanitizeMinErr = angular.$$minErr('$sanitize');
5252
* @returns {string} Sanitized html.
5353
*
5454
* @example
55-
<example module="ngSanitize" deps="angular-sanitize.js">
55+
<example module="sanitizeExample" deps="angular-sanitize.js">
5656
<file name="index.html">
5757
<script>
58-
function Ctrl($scope, $sce) {
59-
$scope.snippet =
60-
'<p style="color:blue">an html\n' +
61-
'<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' +
62-
'snippet</p>';
63-
$scope.deliberatelyTrustDangerousSnippet = function() {
64-
return $sce.trustAsHtml($scope.snippet);
65-
};
66-
}
58+
angular.module('sanitizeExample', ['ngSanitize'])
59+
.controller('ExampleController', ['$scope', '$sce', function($scope, $sce) {
60+
$scope.snippet =
61+
'<p style="color:blue">an html\n' +
62+
'<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' +
63+
'snippet</p>';
64+
$scope.deliberatelyTrustDangerousSnippet = function() {
65+
return $sce.trustAsHtml($scope.snippet);
66+
};
67+
}]);
6768
</script>
68-
<div ng-controller="Ctrl">
69+
<div ng-controller="ExampleController">
6970
Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea>
7071
<table>
7172
<tr>

0 commit comments

Comments
 (0)