Skip to content

Commit 93132b9

Browse files
nicolasbrugneauxpetebacondarwin
authored andcommitted
docs(ngBindHtml): add example
Closes angular#4427
1 parent faf5b98 commit 93132b9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/ng/directive/ngBind.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,29 @@ var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
136136
*
137137
* @element ANY
138138
* @param {expression} ngBindHtml {@link guide/expression Expression} to evaluate.
139+
*
140+
* @example
141+
* Try it here: enter text in text box and watch the greeting change.
142+
<doc:example module="ngBindHtmlExample" deps="angular-sanitize.js" >
143+
<doc:source>
144+
<script>
145+
angular.module('ngBindHtmlExample', ['ngSanitize'])
146+
147+
.controller('ngBindHtmlCtrl', ['$scope', function ngBindHtmlCtrl($scope) {
148+
$scope.myHTML = 'I am an <code>HTML</code>string with <a href="#">links!</a> and other <em>stuff</em>';
149+
}]);
150+
</script>
151+
<div ng-controller="ngBindHtmlCtrl">
152+
<p ng-bind-html="myHTML"></p>
153+
</div>
154+
</doc:source>
155+
<doc:scenario>
156+
it('should check ng-bind-html', function() {
157+
expect(using('.doc-example-live').binding('myHTML')).
158+
toBe('I am an <code>HTML</code>string with <a href="#">links!</a> and other <em>stuff</em>');
159+
});
160+
</doc:scenario>
161+
</doc:example>
139162
*/
140163
var ngBindHtmlDirective = ['$sce', '$parse', function($sce, $parse) {
141164
return function(scope, element, attr) {

0 commit comments

Comments
 (0)