2015-10-02 39 views
4

我發佈了一個早期的問題:angular-ui-bootstrap: Implementing html in popover using popover-html,並建議我使用popover-template。angular-ui:使用popover-template

<i popover-template="popover-partial.html" popover-title="In Progress" class="glyphicon glyphicon-info-sign"></i> 

<script type="text/ng-template" id="popover-partial.html"> 
    <b>Jody</b> 
</script> 

所以我試圖做到這一點,但現在popover不會激活點擊。

我使用的是版本0.13.4。

回答

7

popover-template值應該是string,換句話說,你可以說,它需要一個expression/scopeVariable

<i popover-template="'popover-partial.html'" 
    popover-title="In Progress" 
    class="glyphicon glyphicon-info-sign"> 
</i> 

Demo

+0

我只是改變爲'',它仍然不會在點擊時激活。 –

+0

我的一天。謝謝! – Juan

2

你不得不暴露在模板範圍爲它工作。無論如何,現在您的模板可以通過在範圍上設置變量和模型而變得更加動態,這樣會更好。您還可以設置模板提供程序,以便在您的html代碼下沒有所有這些小腳本標記。

在視圖:

<i popover-template="popover.templateUrl" 
popover-title="popover.title" class="glyphicon glyphicon-info-sign"></i> 

<script type="text/ng-template" id="popover-partial.html"> 
<b>Jody</b> 
</script> 

在你的控制器:

$scope.popover = { 
templateUrl: 'popover-partial.html', 
title: 'Title' 
}; 
+0

像魅力一樣工作,謝謝 – sg28