Latest web development tutorials

AngularJS ng-bind-html instructions

AngularJS Reference Manual AngularJS Reference Manual

AngularJS examples

InnerHTML bind <p> within the variable myText:

<Script src = ""> </ script>
<Script src = ""> </ script>

<Div ng-app = "myApp " ng-controller = "myCtrl">

<P ng-bind-html = "myText"> </ p>

</ Div>

var app = angular.module ( "myApp", [ 'ngSanitize']);
app.controller ( "myCtrl", function ($ scope) {
$ Scope.myText = "My name is: <h1> John Doe </ h1>";
</ Script>

try it"

Definition and Usage

ng-bind-html instruction is through a safe way to bind content to HTML elements.

AngularJS HTML when you want to write in your application, you need to detect dangerous code. By introducing the "angular-santize.js" module in the application, use ngSanitize function to detect security code. in your application you can do so by running the HTML code through the ngSanitize function.


<Element ng-bind-html = "expression"> </ element>

All HTML elements support the instruction.

Parameter Value

value description
expression Specifies that a variable or expression to be executed.

AngularJS Reference Manual AngularJS Reference Manual