1

我在下面在我的HTML代碼片段:角UI引導酥料餅W/HTML不正常

<a ng-href="#" popover popover-template="views/popovers/cu.html" popover-trigger="click" popover-placement="top"> 
    <img ng-src="{{chat.avatar}}" width="50" height="40"> 
</a> 

點擊a標籤不會觸發酥料餅。 Popover在我的應用程序中沒有HTML,但沒有。

我已經基本上覆制從這裏文檔的「酥料餅與模板」部分:https://angular-ui.github.io/bootstrap/#/popover

但它仍然無法正常工作,甚至在例如不之上。

怎麼了?

+1

當你有''酥料餅,template''屬性,也''NG-HREF =「#你不需要''popover''屬性「''沒有必要 –

+0

沒有區別。甚至在我添加它之前它還沒有工作。 – Noah

+0

當你移除''ng-href =「#」''時它有效嗎? –

回答

0

試試這個:假設你沒有使用腳本標記,並且你正在使用一個單獨的html文件,請在你的popover-template中添加一個額外的單引號。在plunkr上查看我的示例。所以應該是popover-template="'cu.html'"而不是popover-template="cu.html"

<a ng-href="#" popover-template="'cu.html'" popover-trigger="click" popover-placement="top" > 
    <img ng-src="{{chat.avatar}}" width="50" height="50"> 
</a>  

編輯:另一種方式實現這一目標是使用腳本標記和具有「文本/ NG-模板」作爲類型。該id將是您在popover-template中放置的文本。看看這個版本plunkr

所以我想看看這個:

<a ng-href="#" popover-template="'cu.html'" popover-trigger="click" popover-placement="top"> 
    <img ng-src="{{chat.avatar}}" width="50" height="50"> 
</a> 

<script type="text/ng-template" id="cu.html"> 
    <div> 
     Hey there! 
    </div> 
</script> 
+0

中的鏈接相同的標記沒有辦法。 – Noah

+0

讓我再試一次.. – Petra

+0

添加了一個替代品。請參閱我的答案的編輯版本。 – Petra