WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-bind-html Directive


Example

Bind the innerHTML of the <p> component to the variable myText:

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/precise sanitize.js"></script>
<body>

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

    <p ng-tie html="myText"></p>

</div>

<script>
var application = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
    $scope.myText = "My name is: <h1>John Doe</h1>";
});
</script>
Try it yourself »

Definition and Usage

The ng-tie html order is a safe method for restricting substance to a HTML element.

When you are letting AngularJS compose HTML in your application, you should check the HTML for hazardous code. By including the "angular-santize.js" module in your application you can do as such by running the HTML code through the ngSanitize function.


Syntax

<element ng-tie html="expression"></element>

Supported by all HTML elements.


Parameter Values

Value Description
expression Specifies a variable, or an articulation to evaluate.