我正在使用Angular UI Bootstrap Popover,但我无法在外部点击时关闭它。我正在使用outsideClick触发器(popover-trigger =“outsideClick”)为什么这不起作用?
<button uib-popover-template="'myPopoverTemplate.html'"
popover-placement="right"class="btn btn-default"
popover-trigger="outsideClick">Click Me</button>
修改 这适用于ui-bootstrap 1.x.x(例如1.3.3)。这是否在2.x.x中不受支持?
答案 0 :(得分:1)
问题出在您的cdn文件中。检查下面的工作代码 -
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.5.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body >
<div ng-controller="PopoverDemoCtrl">
<h1>Popover Test</h1>
<button uib-popover-template="'myPopoverTemplate.html'"
popover-placement="right"
class="btn btn-default" popover-trigger="outsideClick"
>
Click Me
</button>
<script type="text/ng-template" id="myPopoverTemplate.html">
<label> Why does this popover not close on outside click? </label>
</script>
</div>
</body>
</html>
答案 1 :(得分:0)
这是因为在ui-bootstrap 2.x.x上你必须这样做:
popover-trigger="'outsideClick'">Click Me</button>
或使用类似
的内容$scope.myTrigger = "outsideClick" then
popover-trigger="myTrigger">Click Me</button>
感谢@AngularPlayer