简体   繁体   English

如何在 Angular JS 的弹出窗口外单击时隐藏 uib-popover?

[英]How to hide uib-popover on click outside of the popover in angular JS?

<button class="btn btn-default blue btn-lg h-ask btn-block" popover-placement="bottom" uib-popover-template="popover_home.templateUrl">ASK</button>

The above is the code for angular js popover, in the html template of the Popover two input fields also there, so when user submits the html form inside popover i will have control over the popover, but i need to manually close when user opens this popover and does not do any things on the popover(eg: clicking outside the popover).上面是angular js popover的代码,在Popover的html模板中也有两个输入字段,所以当用户在popover中提交html表单时我将控制popover,但是当用户打开它时我需要手动关闭弹出窗口并且不对弹出窗口执行任何操作(例如:在弹出窗口外单击)。

Any idea about this?对此有什么想法吗? I used "popover-trigger='focus'",but it doesnt allows me to write into the input field (whenever hover the popover it closes)我使用了“popover-trigger='focus'”,但它不允许我写入输入字段(每当悬停弹出窗口时它就会关闭)

Don't know which version of angular-ui boostrap you are using, but I'm using the latest (1.1.1) and adding this do the trick:不知道您使用的是哪个版本的 angular-ui boostrap,但我使用的是最新版本 (1.1.1) 并添加此功能:

popover-trigger="outsideClick"

You can see in this demo.你可以在这个演示中看到。

popover close when click outside单击外部时弹出窗口关闭

Hope it helps!希望能帮助到你!

For those who don't read comments:-) Based on @kuanyui comment if it dosen't work with the accepted answer try to add simple cotes '对于那些不阅读评论的人:-) 基于@kuanyui 评论,如果它不适用于已接受的答案,请尝试添加简单的 cotes '

popover-trigger=" 'outsideClick' "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM