2016-05-25 57 views
0

我正在嘗試使用uib-popover-html指令,並且不顯示。如果我使用uib-popover或uib-popover-template指令,它將正確顯示。我錯過了什麼嗎?不顯示角度引導html彈出窗口

這工作

$scope.dynamicPopover = { 
    content: 'Hello, World!', 
    templateUrl: 'app/login/popover.html', 
    title: 'Title' 
}; 


<!-- popover.html --> 
<div> 
    <b style="color: red">I can</b> have <div class="label label-success">HTML</div> content 
</div> 
<!-- /popover.html --> 

<button uib-popover="I appeared on mouse enter!" popover-trigger="mouseenter" type="button" class="btn btn-default">Mouseenter</button> 

<button uib-popover-template="dynamicPopover.templateUrl" popover-title="{{dynamicPopover.title}}" type="button" class="btn btn-default">Popover With Template</button> 

這不

<button uib-popover-html="htmlPopover" class="btn btn-default">HTML Popover</button> 
+0

什麼是在您的uib-popover-html指令中使用的「htmlPopover」? – TSmith

回答

0

嘗試使用$ SCE(嚴格的語境轉義),以表明該HTML是安全的:

$htmlPopover = $sce.trustAsHtml('<div>Popover Content</div>'); 

此功能存在以避免用戶輸入可能是惡意的HTML到表單等等。

參考文獻:https://docs.angularjs.org/api/ng/service/ $ sce