Crhistian Ramirez Crhistian Ramirez - 2 months ago 10
AngularJS Question

The id from binded html does not appear in the DOM

I'm using ng-bind-html and have a div with a class and an id.

<div class="myCustomClass" id="myCustomID">My Content</div>

When I inspect the element I can see the class but the ID is missing. Here is a working plunkr illustrating the issue:


You need to process you html source with $sce service like this:

app.controller('Ctrl', function($scope, $sce) {
  $scope.html = $sce.trustAsHtml('<div id="myID" class="myClass">Inspecting this element shows the class but not the ID</div>');