Crhistian Ramirez Crhistian Ramirez - 1 year ago 71
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:

Answer Source

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>');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download