uib-popover 不会在外部点击时关闭

uib-popover not closing on outside click

我正在使用 Angular UI Bootstrap 弹出窗口,但我无法在外部点击时将其关闭。我使用 outsideClick 触发器 (popover-trigger="outsideClick") 为什么它不起作用?

  <button uib-popover-template="'myPopoverTemplate.html'"  
   popover-placement="right"class="btn btn-default"
   popover-trigger="outsideClick">Click Me</button>

PLUNKER

编辑: 这适用于 ui-bootstrap 1.x.x(例如 1.3.3)。 2.x.x 不支持吗?

问题出在您的 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>

这是因为在 ui-bootstrap 2.x.x 你必须做 :

popover-trigger="'outsideClick'">Click Me</button>

或者使用

$scope.myTrigger = "outsideClick" then
popover-trigger="myTrigger">Click Me</button>

感谢@AngularPlayer