Using HTML Entities within AngularJS strings

You do not need $sce to bind to strings with html. All you need is to inject ngSanitize into your app (it is not a core module), and then use the ng-bind-html attribute directive.

JavaScript

var app = angular.module('app', ['ngSanitize']);

app.controller('MainCtrl', function($scope) {
    $scope.title="&#189; Cookies &amp; <span class="cream">Cream</span>";
});

Html

<div ng-bind-html="title"></div>

Plunkr

Leave a Comment