2016-11-11 13 views
0

私はng-bind-htmlを使用しており、クラスとIDを持つdivを持っています。バインドされたhtmlのIDはDOMに表示されません

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

要素を調べると、クラスが表示されますが、IDはありません。ここでは、問題を示すplunkr作業です:https://plnkr.co/edit/iHeQQI?p=preview

+0

をhttp://stackoverflow.com/questions([この]に見てください/ 24628126/ng-bind-html-doesnt-work-properly)多分それはあなたを助けるでしょう。 –

+0

http://stackoverflow.com/a/28782696/4088809 idがattrのホワイトリストにないようです –

答えて

1

あなたはあなたにこのような$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>'); 
}); 
+0

あなたはようこそ! :) – k10der

関連する問題