0
我正在使用ng-bind-html并且有一个div与一个类和一个id。来自绑定html的id不会出现在DOM中
<div class="myCustomClass" id="myCustomID">My Content</div>
当我检查元素,我可以看到类,但缺少ID。这是一个工作plunkr说明问题:https://plnkr.co/edit/iHeQQI?p=preview
我正在使用ng-bind-html并且有一个div与一个类和一个id。来自绑定html的id不会出现在DOM中
<div class="myCustomClass" id="myCustomID">My Content</div>
当我检查元素,我可以看到类,但缺少ID。这是一个工作plunkr说明问题:https://plnkr.co/edit/iHeQQI?p=preview
您需要处理您$sce
服务这样的HTML源代码:
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>');
});
白名单不客气! :) – k10der
看看[本](http://stackoverflow.com/questions/24628126/ng-bind-html-doesnt-work-properly)也许它会帮助你。 –
http://stackoverflow.com/a/28782696/4088809看起来像id不在attr –