AngularJs – binding HTML

The directive ng-bind will escape HTML to avoid data acting maliciously. If you want to output html you need to use ng-bind-html

<div ng-bind-html=”someHtmlBody”/>

The important step to getting this working is to ensure the script angular-sanitize.js is referenced on your page, and it is specified as a dependency when creating a module….

var app = angular.module(“MyApp”, [“ngSanitize”, “OtherDependencies”]);


Leave a Reply

Your email address will not be published. Required fields are marked *